parameters: (self)
docstring: State of a picking depends on the state of its related stock.move
          - Draft: only used for "planned pickings"
          - Waiting: if the picking is not ready to be sent so if
            - (a) no quantity could be reserved at all or if
            - (b) some quantities could be reserved and the shipping policy is "deliver all at once"
          - Waiting another move: if the picking is waiting for another move
          - Ready: if the picking is ready to be sent so if:
            - (a) all quantities are reserved or if
            - (b) some quantities could be reserved and the shipping policy is "as soon as possible"
          - Done: if the picking is done.
          - Cancelled: if the picking is cancelled
docstring_summary: State of a picking depends on the state of its related stock.move
          - Draft: only used for "planned pickings"
          - Waiting: if the picking is not ready to be sent so if
            - (a) no quantity could be reserved at all or if
            - (b) some quantities could be reserved and the shipping policy is "deliver all at once"
          - Waiting another move: if the picking is waiting for another move
          - Ready: if the picking is ready to be sent so if:
            - (a) all quantities are reserved or if
            - (b) some quantities could be reserved and the shipping policy is "as soon as possible"
          - Done: if the picking is done.
          - Cancelled: if the picking is cancelled
docstring_tokens: State of a picking depends on the state of its related stock . move - Draft : only used for planned pickings - Waiting : if the picking is not ready to be sent so if - ( a ) no quantity could be reserved at all or if - ( b ) some quantities could be reserved and the shipping policy is deliver all at once - Waiting another move : if the picking is waiting for another move - Ready : if the picking is ready to be sent so if : - ( a ) all quantities are reserved or if - ( b ) some quantities could be reserved and the shipping policy is as soon as possible - Done : if the picking is done . - Cancelled : if the picking is cancelled
function: def _compute_state(self):
          ''' State of a picking depends on the state of its related stock.move
          - Draft: only used for "planned pickings"
          - Waiting: if the picking is not ready to be sent so if
            - (a) no quantity could be reserved at all or if
            - (b) some quantities could be reserved and the shipping policy is "deliver all at once"
          - Waiting another move: if the picking is waiting for another move
          - Ready: if the picking is ready to be sent so if:
            - (a) all quantities are reserved or if
            - (b) some quantities could be reserved and the shipping policy is "as soon as possible"
          - Done: if the picking is done.
          - Cancelled: if the picking is cancelled
          '''
          picking_moves_state_map = defaultdict(dict)
          picking_move_lines = defaultdict(set)
          for move in self.env['stock.move'].search([('picking_id', 'in', self.ids)]):
              picking_id = move.picking_id
              move_state = move.state
              picking_moves_state_map[picking_id.id].update({
                  'any_draft': picking_moves_state_map[picking_id.id].get('any_draft', False) or move_state == 'draft',
                  'all_cancel': picking_moves_state_map[picking_id.id].get('all_cancel', True) and move_state == 'cancel',
                  'all_cancel_done': picking_moves_state_map[picking_id.id].get('all_cancel_done', True) and move_state in ('cancel', 'done'),
              })
              picking_move_lines[picking_id.id].add(move.id)
          for picking in self:
              picking_id = (picking.ids and picking.ids[0]) or picking.id
              if not picking_moves_state_map[picking_id]:
                  picking.state = 'draft'
              elif picking_moves_state_map[picking_id]['any_draft']:
                  picking.state = 'draft'
              elif picking_moves_state_map[picking_id]['all_cancel']:
                  picking.state = 'cancel'
              elif picking_moves_state_map[picking_id]['all_cancel_done']:
                  picking.state = 'done'
              else:
                  relevant_move_state = self.env['stock.move'].browse(picking_move_lines[picking_id])._get_relevant_state_among_moves()
                  if picking.immediate_transfer and relevant_move_state not in ('draft', 'cancel', 'done'):
                      picking.state = 'assigned'
                  elif relevant_move_state == 'partially_available':
                      picking.state = 'assigned'
                  else:
                      picking.state = relevant_move_state
function_tokens: def _compute_state ( self ) : picking_moves_state_map = defaultdict ( dict ) picking_move_lines = defaultdict ( set ) for move in self . env [ 'stock.move' ] . search ( [ ( 'picking_id' , 'in' , self . ids ) ] ) : picking_id = move . picking_id move_state = move . state picking_moves_state_map [ picking_id . id ] . update ( { 'any_draft' : picking_moves_state_map [ picking_id . id ] . get ( 'any_draft' , False ) or move_state == 'draft' , 'all_cancel' : picking_moves_state_map [ picking_id . id ] . get ( 'all_cancel' , True ) and move_state == 'cancel' , 'all_cancel_done' : picking_moves_state_map [ picking_id . id ] . get ( 'all_cancel_done' , True ) and move_state in ( 'cancel' , 'done' ) , } ) picking_move_lines [ picking_id . id ] . add ( move . id ) for picking in self : picking_id = ( picking . ids and picking . ids [ 0 ] ) or picking . id if not picking_moves_state_map [ picking_id ] : picking . state = 'draft' elif picking_moves_state_map [ picking_id ] [ 'any_draft' ] : picking . state = 'draft' elif picking_moves_state_map [ picking_id ] [ 'all_cancel' ] : picking . state = 'cancel' elif picking_moves_state_map [ picking_id ] [ 'all_cancel_done' ] : picking . state = 'done' else : relevant_move_state = self . env [ 'stock.move' ] . browse ( picking_move_lines [ picking_id ] ) . _get_relevant_state_among_moves ( ) if picking . immediate_transfer and relevant_move_state not in ( 'draft' , 'cancel' , 'done' ) : picking . state = 'assigned' elif relevant_move_state == 'partially_available' : picking . state = 'assigned' else : picking . state = relevant_move_state