@@ -645,6 +645,17 @@ class StockMove(models.Model):
|
||||
}
|
||||
}
|
||||
|
||||
def _search_picking_for_assignation(self):
|
||||
self.ensure_one()
|
||||
picking = self.env['stock.picking'].search([
|
||||
('group_id', '=', self.group_id.id),
|
||||
('location_id', '=', self.location_id.id),
|
||||
('location_dest_id', '=', self.location_dest_id.id),
|
||||
('picking_type_id', '=', self.picking_type_id.id),
|
||||
('printed', '=', False),
|
||||
('state', 'in', ['draft', 'confirmed', 'waiting', 'partially_available', 'assigned'])], limit=1)
|
||||
return picking
|
||||
|
||||
def _assign_picking(self):
|
||||
""" Try to assign the moves to an existing picking that has not been
|
||||
reserved yet and has the same procurement group, locations and picking
|
||||
@@ -653,13 +664,7 @@ class StockMove(models.Model):
|
||||
Picking = self.env['stock.picking']
|
||||
for move in self:
|
||||
recompute = False
|
||||
picking = Picking.search([
|
||||
('group_id', '=', move.group_id.id),
|
||||
('location_id', '=', move.location_id.id),
|
||||
('location_dest_id', '=', move.location_dest_id.id),
|
||||
('picking_type_id', '=', move.picking_type_id.id),
|
||||
('printed', '=', False),
|
||||
('state', 'in', ['draft', 'confirmed', 'waiting', 'partially_available', 'assigned'])], limit=1)
|
||||
picking = move._search_picking_for_assignation()
|
||||
if picking:
|
||||
if picking.partner_id.id != move.partner_id.id or picking.origin != move.origin:
|
||||
# If a picking is found, we'll append `move` to its move list and thus its
|
||||
|
||||
Reference in New Issue
Block a user