<commit_before>##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields, api


class StockPicking(models.Model):

    _inherit = 'stock.picking'

    state_detail_id = fields.Many2one(
        'stock.picking.state_detail',
        string='State Detail',
        track_visibility='onchange',
        index=True,
        copy=False,
    )

    @api.constrains('state')
    def change_state(self):
        for rec in self:
            domain = [
                ('state', '=', rec.state),
                ('picking_type', '=', rec.picking_type_code)]
            state_detail = self.env['stock.picking.state_detail'].search(
                domain, limit=1, order="sequence asc")
            rec.state_detail_id = state_detail<commit_msg>[12.0] [FIX] stock_picking_state: Changes in auto subestate allocation (#209)<commit_after>##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields, api


class StockPicking(models.Model):

    _inherit = 'stock.picking'

    state_detail_id = fields.Many2one(
        'stock.picking.state_detail',
        string='State Detail',
        track_visibility='onchange',
        index=True,
        copy=False,
    )

    @api.constrains('state')
    def change_state(self):
        for rec in self:
            domain = [
                ('state', '=', rec.state),
                ('picking_type', '=', rec.picking_type_code)]
            state_detail = self.env['stock.picking.state_detail'].search(domain, order="sequence asc")
            if self.state_detail_id and self.state_detail_id in state_detail:
                continue
            rec.state_detail_id = state_detail and state_detail[0]
{'fraction_non_alphanumeric': 0.24385542168674698, 'fraction_numerical': 0.004819277108433735, 'mean_word_length': 3.1770623742454727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3215313', 'n_tokens_mistral': 566, 'n_tokens_neox': 527, 'n_words': 116}