[FIX] mrp: handle by_products

When creating by products during a workorder the move lines
for the final moves are not created and the user has to manually
create them on the manufacturing order view.

This commit adds an automatic action in order to create
the correct move lines with the consumed quantity for the
by products not tracked by lot or SN.

This commit also fixes a bug where the consumed move lines where
not linked to the by products move lines
This commit is contained in:
Arnold Moyaux
2017-12-04 13:44:40 +01:00
parent 2afedc99a6
commit 9c4c51f417
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -549,7 +549,7 @@ class MrpProduction(models.Model):
#order.action_assign()
consume_move_lines = moves_to_do.mapped('active_move_line_ids')
for moveline in moves_to_finish.mapped('active_move_line_ids'):
if moveline.move_id.has_tracking != 'none':
if moveline.product_id == order.product_id and moveline.move_id.has_tracking != 'none':
if any([not ml.lot_produced_id for ml in consume_move_lines]):
raise UserError(_('You can not consume without telling for which lot you consumed it'))
# Link all movelines in the consumed with same lot_produced_id false or the correct lot_produced_id
+6
View File
@@ -355,6 +355,12 @@ class MrpWorkorder(models.Model):
})
else:
production_move.quantity_done += self.qty_producing
if not self.next_work_order_id:
for by_product_move in self.production_id.move_finished_ids.filtered(lambda x: (x.product_id.id != self.production_id.product_id.id) and (x.state not in ('done', 'cancel'))):
if by_product_move.has_tracking == 'none':
by_product_move.quantity_done += self.qty_producing * by_product_move.unit_factor
# Update workorder quantity produced
self.qty_produced += self.qty_producing