From 6c39b5c90c662bc6d5eae44dbd0a5aa9e76473ee Mon Sep 17 00:00:00 2001 From: Nidhi Patel Date: Tue, 7 Jan 2020 13:21:27 +0000 Subject: [PATCH] [FIX] mrp: traceback on multiple MO deletion _log_downside_manufactured_quantity is an api.one method since it would log the production info on the generated acitivty. Since commit b499c3308cd036e464578045996b63cfa877aa92, an unlink will trigger an _action_cancel on unlinked MO. So unlink multiple MO will call _log_downside_manufactured_quantity with multiple records and traceback. closes odoo/odoo#42892 Task-id: 2168386 Signed-off-by: Arnold Moyaux --- addons/mrp/models/mrp_production.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index a86bb909161..56807a26c93 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -929,14 +929,15 @@ class MrpProduction(models.Model): documents[key] += [value] if documents: documents_by_production[production] = documents + # log an activity on Parent MO if child MO is cancelled. + finish_moves = production.move_finished_ids.filtered(lambda x: x.state not in ('done', 'cancel')) + if finish_moves: + production._log_downside_manufactured_quantity({finish_move: (production.product_uom_qty, 0.0) for finish_move in finish_moves}, cancel=True) self.workorder_ids.filtered(lambda x: x.state not in ['done', 'cancel']).action_cancel() finish_moves = self.move_finished_ids.filtered(lambda x: x.state not in ('done', 'cancel')) raw_moves = self.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')) - # log an activity on Parent MO if child MO is cancelled. - if finish_moves: - self._log_downside_manufactured_quantity({finish_move: (self.product_uom_qty, 0.0) for finish_move in finish_moves}, cancel=True) (finish_moves | raw_moves)._action_cancel() picking_ids = self.picking_ids.filtered(lambda x: x.state not in ('done', 'cancel')) picking_ids.action_cancel()