summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNidhi Patel <nia@odoo.com>2020-01-07 13:21:27 +0000
committerArnold Moyaux <arm@odoo.com>2020-01-08 09:25:37 +0000
commit6c39b5c90c662bc6d5eae44dbd0a5aa9e76473ee (patch)
tree69c4ca10426d2c09ccdec9fd327a844a3c0e554a
parentea4783be014021f27e9c0c7989dfe162fe81d469 (diff)
[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 <amoyaux@users.noreply.github.com>
-rw-r--r--addons/mrp/models/mrp_production.py7
1 files 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()