Skip to content
Permalink
Browse files

[FIX] mrp: Duplicate finished_move_line_ids from by_product in a BOM

Steps to reproduce the bug:

- Create product A (type='product',tracking='lot')

- Create product B (type='product',tracking='lot')

- Create product Z(type='consu',tracking='none')

- Create BoM for product Z with product A as component and product B
as sub_product (i.e. By product) + create any routing (i.e. 1 operation).

- Create an MO for product z, plan it, process the given work order,
input the serial/lot for the components and byproducts...

Bug:

Two lines for product B were displayed in the finished_move_line_ids of the MO

This bug occured in enterprise because the function _create_checks defined on model
'mrp.workorder' creates the quality checks that create the finished_move_line_ids
for the by_product tracked by lot or by serial number (in fuction _update_active_move_line
defined on model 'mrp.workorder').

So the finished_move_line_ids were created two times with the ones created in fuction record_production
defined on model 'mrp.workorder' in community.

Co-authored-by: amoyaux <arm@odoo.com>

opw:1963163
  • Loading branch information...
simongoffin committed Apr 17, 2019
1 parent 19aa7c4 commit 16924268c1699838eb8703b2886873d36b6b966e
Showing with 11 additions and 8 deletions.
  1. +11 −8 addons/mrp/models/mrp_workorder.py
@@ -370,15 +370,15 @@ def record_production(self):
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 != 'serial':
values = self._get_byproduct_move_line(by_product_move, self.qty_producing * by_product_move.unit_factor)
self.env['stock.move.line'].create(values)
elif by_product_move.has_tracking == 'serial':
qty_todo = by_product_move.product_uom._compute_quantity(self.qty_producing * by_product_move.unit_factor, by_product_move.product_id.uom_id)
for i in range(0, int(float_round(qty_todo, precision_digits=0))):
values = self._get_byproduct_move_line(by_product_move, 1)
for by_product_move in self._get_byproduct_move_to_update():
if by_product_move.has_tracking != 'serial':
values = self._get_byproduct_move_line(by_product_move, self.qty_producing * by_product_move.unit_factor)
self.env['stock.move.line'].create(values)
elif by_product_move.has_tracking == 'serial':
qty_todo = by_product_move.product_uom._compute_quantity(self.qty_producing * by_product_move.unit_factor, by_product_move.product_id.uom_id)
for i in range(0, int(float_round(qty_todo, precision_digits=0))):
values = self._get_byproduct_move_line(by_product_move, 1)
self.env['stock.move.line'].create(values)

# Update workorder quantity produced
self.qty_produced += self.qty_producing
@@ -409,6 +409,9 @@ def record_production(self):
self.button_finish()
return True

def _get_byproduct_move_to_update(self):
return 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')))

@api.multi
def _start_nextworkorder(self):
rounding = self.product_id.uom_id.rounding

0 comments on commit 1692426

Please sign in to comment.
You can’t perform that action at this time.