From 3d4c0f92af86e534bc44ed48eb0ebf2ade3f7a92 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Fri, 14 Jun 2019 14:23:22 +0000 Subject: [PATCH] [FIX] mrp: log activity on parent MO Usecase: - Set table top as manufacture and MTO - Create a MO for table(MTO) - Confirm the MO - Cancel the MO The activity with the exception is not logged on the child MO It happens because the _get_upstream_documents_and_responsible for move linked to a MO is based on the created_production_id field. However it is only set on the move that created the move_finished_ids for the new MO. In the case of a MO that directly create a child MO the chain is: MO -> move_raw_ids -> move_finished_ids -> MO2 The log_activity on cancel is based on the move_raw_ids and their move_orig_ids in the previous case it's the move_finished_ids for MO2. However the move_finished_ids for MO2 is directly link to the child MO and the created_production_id is set on the move_raw_ids for MO parent. Compare to PO, we could directly base the parent document on production_id since the move_finished_ids are directly created. --- addons/mrp/models/stock_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 5c0de7462d4..df0452c0539 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -216,8 +216,8 @@ class StockMove(models.Model): return self.env['stock.move'] def _get_upstream_documents_and_responsibles(self, visited): - if self.created_production_id and self.created_production_id.state not in ('done', 'cancel'): - return [(self.created_production_id, self.created_production_id.user_id, visited)] + if self.production_id and self.production_id.state not in ('done', 'cancel'): + return [(self.production_id, self.production_id.user_id, visited)] else: return super(StockMove, self)._get_upstream_documents_and_responsibles(visited)