[IMP] mrp: picking_type_id on stock.moves

No picking_type_id is set on move created in Manufacturing orders, so
when you sort/group by your all your moves in a tree view, you cannot
easily identify the ones that belong to Manufacturing orders.

So we've added the picking_type_id of the MO on the moves, but also had
to addapt the condition to know which move having a picking_type_id and
no picking must be assigned to a picking.

opw:1863591
This commit is contained in:
Simon Lejeune
2018-08-30 16:16:54 +02:00
committed by Pierre Masereel
parent cc62784924
commit d6d27e3777
3 changed files with 10 additions and 2 deletions
+2
View File
@@ -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,
+3 -1
View File
@@ -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))
+5 -1
View File
@@ -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']