[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 closes odoo/odoo#32779 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -370,15 +370,15 @@ class MrpWorkorder(models.Model):
|
||||
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 @@ class MrpWorkorder(models.Model):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user