From f060e3df0a95204f93596d71b0726d409c4d6375 Mon Sep 17 00:00:00 2001 From: Nicolas Galler Date: Mon, 23 Nov 2020 16:08:12 +0000 Subject: [PATCH] [FIX] mrp: carry over origin from source move in 3-step mfr Behavior prior to this commit: - when the warehouse uses a 3-step manufacturing process, if I create a Sales Order, the MO generated does not show the SO# as "Source", instead it shows the MO# Behavior after this commit: - the MO source shows the SO# (similar to how it works when using the 2-step or the 1-step manufacturing process) - the origins are assigned thus: - Delivery Picking = SO name - Post-prod Picking = SO name - MO = SO name - Pre-prod Picking = MO name Note: - there is no implementation change in this commit - we just ported the test from the original commit in 13.0 (the behavior in 14.0 was already OK) opw-2380717 closes odoo/odoo#62512 X-original-commit: 0281dee6da75e68403772ebd368d57c1feb98c37 Signed-off-by: Nicolas Galler --- addons/mrp/tests/test_warehouse_multistep_manufacturing.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/mrp/tests/test_warehouse_multistep_manufacturing.py b/addons/mrp/tests/test_warehouse_multistep_manufacturing.py index 9f1509673fb..d9e6f840950 100644 --- a/addons/mrp/tests/test_warehouse_multistep_manufacturing.py +++ b/addons/mrp/tests/test_warehouse_multistep_manufacturing.py @@ -150,11 +150,14 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): 'location_id': self.warehouse.wh_output_stock_loc_id.id, 'location_dest_id': self.customer_location, 'procure_method': 'make_to_order', + 'origin': 'SOURCEDOCUMENT', 'state': 'draft', }) picking_customer.action_confirm() production_order = self.env['mrp.production'].search([('product_id', '=', self.finished_product.id)]) self.assertTrue(production_order) + self.assertEqual(production_order.origin, 'SOURCEDOCUMENT', 'The MO origin should be the SO name') + self.assertNotEqual(production_order.name, 'SOURCEDOCUMENT', 'The MO name should not be the origin of the move') picking_stock_preprod = self.env['stock.move'].search([ ('product_id', '=', self.raw_product.id), @@ -173,6 +176,8 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon): self.assertTrue(picking_stock_postprod) self.assertEqual(picking_stock_preprod.state, 'confirmed') self.assertEqual(picking_stock_postprod.state, 'waiting') + self.assertEqual(picking_stock_preprod.origin, production_order.name, 'The pre-prod origin should be the MO name') + self.assertEqual(picking_stock_postprod.origin, 'SOURCEDOCUMENT', 'The post-prod origin should be the SO name') picking_stock_preprod.action_assign() picking_stock_preprod.move_line_ids.qty_done = 4