'State of a picking depends on the state of its related stock.move
- no moves: draft or assigned (launch_pack_operations)
- all moves canceled: cancel
- all moves done (including possible canceled): done
- All at once picking: least of confirmed / waiting / assigned
- Partial picking
- all moves assigned: assigned
- one of the move is assigned or partially available: partially available
- otherwise in waiting or confirmed state'

@api.depends('move_type', 'launch_pack_operations', 'move_lines.state', 'move_lines.picking_id', 'move_lines.partially_available')
@api.one
def _compute_state(self):

    if ((not self.move_lines) and self.launch_pack_operations):
        self.state = 'assigned'
    elif (not self.move_lines):
        self.state = 'draft'
    elif any(((move.state == 'draft') for move in self.move_lines)):
        self.state = 'draft'
    elif all(((move.state == 'cancel') for move in self.move_lines)):
        self.state = 'cancel'
    elif all(((move.state in ['cancel', 'done']) for move in self.move_lines)):
        self.state = 'done'
    else:
        moves_todo = self.move_lines.filtered((lambda move: (move.state not in ['cancel', 'done']))).sorted(key=(lambda move: (((move.state == 'assigned') and 2) or ((move.state == 'waiting') and 1) or 0)))
        if (self.move_type == 'one'):
            self.state = (moves_todo[0].state or 'draft')
        elif ((moves_todo[0].state != 'assigned') and any(((x.partially_available or (x.state == 'assigned')) for x in moves_todo))):
            self.state = 'partially_available'
        else:
            self.state = (moves_todo[(-1)].state or 'draft')
