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.

opw:1963163
  • Loading branch information...
simongoffin committed Apr 17, 2019
1 parent 19aa7c4 commit 4e0e8504d93058bbc62143f549a564e38e63c302
Showing with 11 additions and 7 deletions.
  1. +11 −7 addons/mrp/models/mrp_workorder.py
@@ -371,14 +371,15 @@ def record_production(self):

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)
if not self._is_created_from_quality_check(by_product_move):
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 +410,9 @@ def record_production(self):
self.button_finish()
return True

def _is_created_from_quality_check(self, by_product_move):
return False

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

0 comments on commit 4e0e850

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