From c2040da0bafc0bc341bbd1fa72a62ef94db79bd3 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 8 Dec 2016 11:10:58 +0100 Subject: [PATCH] [REF] mrp: inventory post when last work order is finished Before this patch, the inventory was automatically posted when you click on "done" on the last planned work order. This behavior was preventing the user from correcting, for example, the consumed quantity on the raw materials move on the manufacturing order if it was different from the theoretical quantity. Note that finishing anyone but the last work order still let you edit the consumed quantity. Same with changing the lot. Now you have to click on "mark as done" on the manufacturing order to post the inventory. Note that this is the same behavior when working without work order (produce > mark as done will post). We adapt the tests to reflect this change. --- addons/mrp/models/mrp_workorder.py | 2 -- addons/mrp/tests/test_workorder_operation.py | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index dbc0ee221c2..fc0da1ecdab 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -377,8 +377,6 @@ class MrpWorkorder(models.Model): self.ensure_one() self.end_all() self.write({'state': 'done', 'date_finished': fields.Datetime.now()}) - if not self.production_id.workorder_ids.filtered(lambda x: x.state not in ('done','cancel')): - self.production_id.post_inventory() # User should put it to done manually @api.multi def end_previous(self, doall=False): diff --git a/addons/mrp/tests/test_workorder_operation.py b/addons/mrp/tests/test_workorder_operation.py index 00541dfc8df..14eb7a65b31 100644 --- a/addons/mrp/tests/test_workorder_operation.py +++ b/addons/mrp/tests/test_workorder_operation.py @@ -123,9 +123,10 @@ class TestWorkOrderProcess(common.TransactionCase): # This behaviour was changed #self.assertEqual(production_table.state, 'done', "Production order should be in done state.") - # ---------------------------------------- - # Check consume quants and produce quants. - # ---------------------------------------- + # --------------------------------------------------------------- + # Check consume quants and produce quants after posting inventory + # --------------------------------------------------------------- + production_table.button_mark_done() self.assertEqual(sum(move_table_sheet.quant_ids.mapped('qty')), 1, "Wrong quantity of consumed product %s" % move_table_sheet.product_id.name) self.assertEqual(sum(move_leg.quant_ids.mapped('qty')), 4, "Wrong quantity of consumed product %s" % move_leg.product_id.name) self.assertEqual(sum(move_table_bolt.quant_ids.mapped('qty')), 4, "Wrong quantity of consumed product %s" % move_table_bolt.product_id.name)