diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 993766ebec7..73c9790a25a 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -393,6 +393,7 @@ class MrpProduction(models.Model): 'name': self.name, 'date': self.date_planned_start, 'date_expected': self.date_planned_start, + 'picking_type_id': self.picking_type_id.id, 'product_id': self.product_id.id, 'product_uom': self.product_uom_id.id, 'product_uom_qty': self.product_qty, @@ -439,6 +440,7 @@ class MrpProduction(models.Model): 'date': self.date_planned_start, 'date_expected': self.date_planned_start, 'bom_line_id': bom_line.id, + 'picking_type_id': self.picking_type_id.id, 'product_id': bom_line.product_id.id, 'product_uom_qty': quantity, 'product_uom': bom_line.product_uom_id.id, diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 3980dab4b3f..b76a77ccc44 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -262,4 +262,6 @@ class StockMove(models.Model): else: return super(StockMove, self)._get_upstream_documents_and_responsibles(visited) - + def _should_be_assigned(self): + res = super(StockMove, self)._should_be_assigned() + return bool(res and not (self.production_id or self.raw_material_production_id)) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 9758f356375..e6fc2209231 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -731,6 +731,10 @@ class StockMove(models.Model): 'location_dest_id': self.location_dest_id.id, } + def _should_be_assigned(self): + self.ensure_one() + return bool(not self.picking_id and self.picking_type_id) + def _action_confirm(self, merge=True, merge_into=False): """ Confirms stock move or put it in waiting if it's linked to another move. :param: merge: According to this boolean, a newly confirmed move will be merged @@ -750,7 +754,7 @@ class StockMove(models.Model): move_create_proc |= move else: move_to_confirm |= move - if not move.picking_id and move.picking_type_id: + if move._should_be_assigned(): key = (move.group_id.id, move.location_id.id, move.location_dest_id.id) if key not in to_assign: to_assign[key] = self.env['stock.move']