From c5b3f41fbd442def9e97acb023a00862e7d03eb3 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Tue, 7 Aug 2018 13:57:06 +0200 Subject: [PATCH] [IMP] mrp: new procurement group for MTO manufacture product The purpose is to split up the supply chain in different group. Currently if a user create a SO with a MTO manufacture product that use MTO/buy components. SO cancellation will: - Cancel all the pickings including pickings between MO and suppliers. - Log an activity on the MO but not cancel it. We prefer cancel all transfers between SO and MO when the SO is cancel. Cancel all the transfers between MO and suppliers when the MO is cancel. Create a new procurement group when the _run_manufacture method is call allows to achieve this behavior. --- addons/mrp/models/stock_rule.py | 2 +- addons/sale_mrp/tests/test_sale_mrp_flow.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/stock_rule.py b/addons/mrp/models/stock_rule.py index 6b31506afe0..d2bcdbbbafe 100644 --- a/addons/mrp/models/stock_rule.py +++ b/addons/mrp/models/stock_rule.py @@ -71,7 +71,7 @@ class StockRule(models.Model): 'bom_id': bom.id, 'date_planned_start': fields.Datetime.to_string(self._get_date_planned(product_id, values)), 'date_planned_finished': values['date_planned'], - 'procurement_group_id': values.get('group_id').id if values.get('group_id', False) else False, + 'procurement_group_id': False, 'propagate': self.propagate, 'picking_type_id': self.picking_type_id.id or values['warehouse_id'].manu_type_id.id, 'company_id': values['company_id'].id, diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py index ec10d718d13..acd9cd409ac 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_flow.py +++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py @@ -215,7 +215,7 @@ class TestSaleMrpFlow(common.TransactionCase): # <><><><><><><><><><><><><><><><><><><><><><> # FP Todo: find a better way to look for the production order - mnf_product_d = self.MrpProduction.search([('product_id', '=', product_d.id), ('move_dest_ids.group_id', '=', order.procurement_group_id.id)], order='id desc', limit=1) + mnf_product_d = self.MrpProduction.search([('product_id', '=', product_d.id)], order='id desc', limit=1) # Check state of production order D. self.assertEqual(mnf_product_d.state, 'confirmed', 'Manufacturing order should be confirmed.')