From 0bbdfe1305c8577ec0bbd82b2fa469bdcb7b4c2d Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sat, 29 Aug 2015 23:37:29 +0200 Subject: [PATCH] [FIX] MRP fix in production operation [IMP] removing phantom on bom.line --- addons/mrp/mrp.py | 2 +- addons/mrp/mrp_demo.xml | 70 +++++++-------------- addons/mrp/mrp_view.xml | 6 +- addons/product/product_demo.xml | 10 +-- addons/sale/report/sale_report_view.xml | 6 +- addons/sale_mrp/tests/test_sale_mrp_flow.py | 31 +++------ 6 files changed, 43 insertions(+), 82 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 60fcf5b5ffd..c1642412642 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1001,7 +1001,7 @@ class mrp_production(osv.osv): if not float_is_zero(remaining_qty, precision_digits=precision): #consumed more in wizard than previously planned product = self.pool.get('product.product').browse(cr, uid, consume['product_id'], context=context) - extra_move_id = self._make_consume_line_from_data(cr, uid, production, product, product.uom_id.id, remaining_qty, False, 0, context=context) + extra_move_id = self._make_consume_line_from_data(cr, uid, production, product, product.uom_id.id, remaining_qty, context=context) stock_mov_obj.write(cr, uid, [extra_move_id], {'restrict_lot_id': consume['lot_id'], 'consumed_for': main_production_move}, context=context) stock_mov_obj.action_done(cr, uid, [extra_move_id], context=context) diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index e6e85b8e96a..3cd918d5e41 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -238,12 +238,14 @@ + + + - 5 + 5 - normal @@ -251,16 +253,17 @@ 2 5 - normal + + + 5 - normal @@ -268,7 +271,6 @@ 4 5 - normal @@ -276,7 +278,6 @@ 10 - normal @@ -284,16 +285,17 @@ 1 5 - normal + + + 5 - normal @@ -301,7 +303,6 @@ 1 2 - normal @@ -310,7 +311,6 @@ 1 4 - normal @@ -319,7 +319,6 @@ 1 6 - normal @@ -327,7 +326,6 @@ 10 - normal @@ -335,7 +333,6 @@ 1 2 - normal @@ -344,7 +341,6 @@ 1 4 - normal @@ -353,15 +349,16 @@ 1 6 - normal + + + 5 - normal @@ -369,7 +366,6 @@ 1 4 - normal @@ -378,7 +374,6 @@ 1 6 - normal @@ -387,7 +382,6 @@ 1 8 - normal @@ -395,7 +389,6 @@ 10 - normal @@ -403,7 +396,6 @@ 1 2 - normal @@ -412,7 +404,6 @@ 1 4 - normal @@ -421,7 +412,6 @@ 1 6 - normal @@ -430,22 +420,22 @@ 1 10 - normal + + + 5 - normal 5 - normal @@ -463,7 +453,6 @@ 1 2 - normal @@ -472,7 +461,6 @@ 1 4 - normal @@ -481,7 +469,6 @@ 1 6 - normal @@ -490,7 +477,6 @@ 1 8 - normal @@ -499,7 +485,6 @@ 2 10 - normal @@ -516,7 +501,6 @@ 1 2 - normal @@ -525,7 +509,6 @@ 1 4 - normal @@ -534,7 +517,6 @@ 1 6 - normal @@ -543,7 +525,6 @@ 1 8 - normal @@ -552,10 +533,12 @@ 1 10 - normal + + + @@ -569,7 +552,6 @@ 1 2 - normal @@ -578,7 +560,6 @@ 1 4 - normal @@ -587,7 +568,6 @@ 1 6 - normal @@ -596,7 +576,6 @@ 1 8 - normal @@ -605,22 +584,22 @@ 1 10 - normal + + + 1 - normal 1 1 - normal @@ -629,7 +608,6 @@ 1 2 - normal @@ -638,7 +616,6 @@ 1 3 - normal @@ -647,7 +624,6 @@ 1 1 - normal @@ -657,7 +633,6 @@ 1 1 - normal @@ -667,7 +642,6 @@ 1 1 - normal diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 7b44e84d72c..ee023b9d0df 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -406,7 +406,7 @@ - + @@ -514,7 +514,7 @@ - + @@ -950,7 +950,7 @@ - + diff --git a/addons/product/product_demo.xml b/addons/product/product_demo.xml index 4170c3bb16f..f69817a024f 100644 --- a/addons/product/product_demo.xml +++ b/addons/product/product_demo.xml @@ -80,7 +80,7 @@ - PC Assemble SC234 + Computer SC234 450.0 300.0 @@ -204,14 +204,14 @@ FaceTime HD Camera, 1.2 MP Photos - PC Assemble + Custom (PC on Demand) + Custom Computer (kit) 600.0 147.0 consu - Custom computer assembled on order based on customer's requirement. + Custom computer shipped in kit. B3424 @@ -330,7 +330,7 @@ FaceTime HD Camera, 1.2 MP Photos - RAM SR2 + RAM SR2 (kit) 87.0 95.0 @@ -374,7 +374,7 @@ FaceTime HD Camera, 1.2 MP Photos - HDD SH-2 + HDD SH-2 (mto) 1020.0 1150.0 diff --git a/addons/sale/report/sale_report_view.xml b/addons/sale/report/sale_report_view.xml index 092c37ba451..c91414f76bf 100644 --- a/addons/sale/report/sale_report_view.xml +++ b/addons/sale/report/sale_report_view.xml @@ -7,8 +7,8 @@ sale.report - - + + @@ -19,7 +19,7 @@ sale.report - + diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py index d8c703a6ba3..5c8d7cc8dad 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_flow.py +++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py @@ -42,11 +42,10 @@ class TestSaleMrpFlow(common.TransactionCase): 'uom_po_id': uom_id, 'route_ids': route_ids}) - def create_bom_lines(bom_id, product_id, qty, uom_id, bom_type): + def create_bom_lines(bom_id, product_id, qty, uom_id): self.MrpBomLine.create({ 'product_id': product_id, 'product_qty': qty, - 'type': bom_type, 'bom_id': bom_id, 'product_uom': uom_id}) @@ -97,18 +96,17 @@ class TestSaleMrpFlow(common.TransactionCase): # Bill of materials for Product A. bom_a = create_bom(product_a.product_tmpl_id.id, 2, self.uom_dozen.id, 'normal') - create_bom_lines(bom_a.id, product_b.id, 3, self.uom_unit.id, 'phantom') - create_bom_lines(bom_a.id, product_c.id, 300.5, self.uom_gm.id, 'normal') - create_bom_lines(bom_a.id, product_d.id, 4, self.uom_unit.id, 'phantom') - create_bom_lines(bom_a.id, product_d.id, 4, self.uom_unit.id, 'normal') + create_bom_lines(bom_a.id, product_b.id, 3, self.uom_unit.id) + create_bom_lines(bom_a.id, product_c.id, 300.5, self.uom_gm.id) + create_bom_lines(bom_a.id, product_d.id, 4, self.uom_unit.id) # Bill of materials for Product B. bom_b = create_bom(product_b.product_tmpl_id.id, 1, self.uom_unit.id, 'phantom') - create_bom_lines(bom_b.id, product_c.id, 0.400, self.uom_kg.id, 'normal') + create_bom_lines(bom_b.id, product_c.id, 0.400, self.uom_kg.id) # Bill of materials for Product D. bom_d = create_bom(product_d.product_tmpl_id.id, 1, self.uom_unit.id, 'normal') - create_bom_lines(bom_d.id, product_c.id, 1, self.uom_kg.id, 'normal') + create_bom_lines(bom_d.id, product_c.id, 1, self.uom_kg.id) # ---------------------------------------- # Create sale order of 10 Dozen product A. @@ -152,14 +150,6 @@ class TestSaleMrpFlow(common.TransactionCase): # then for 10 Dozen product A will consume 1502.5 gm product C. # ] # - # Product C 20 kg - # As product D phantom in bom A, product A will consume product C. - # ================================================================ - # For 1 unit product D will consume 1 kg product C - # then for 20 unit ( Product D 4 unit per 2 Dozen product A) - # product D it will consume [ 20 kg ] product C, - # Product A will consume 20 kg product C. - # # product D 20 Unit. # [ # For 2 dozen product A will consume 4 unit product D @@ -198,9 +188,10 @@ class TestSaleMrpFlow(common.TransactionCase): ('product_uom', '=', self.uom_kg.id)]) # Check total consume line with product c and uom kg. - self.assertEqual(len(moves), 2, 'Production move lines are not generated proper.') + self.assertEqual(len(moves), 1, 'Production move lines are not generated proper.') list_qty = [move.product_uom_qty for move in moves] - self.assertEqual(set(list_qty), set([6.0, 20.0]), "Wrong product quantity in 'To consume line' of manufacturing order.") + print '***', list_qty + self.assertEqual(set(list_qty), set([6.0]), "Wrong product quantity in 'To consume line' of manufacturing order.") # Check state of consume line with product c and uom kg. for move in moves: self.assertEqual(move.state, 'confirmed', "Wrong state in 'To consume line' of manufacturing order.") @@ -229,10 +220,6 @@ class TestSaleMrpFlow(common.TransactionCase): # Check total consume line with product D. self.assertEqual(len(move), 1, 'Production lines are not generated proper.') - # Check state of consume line with product D. - self.assertEqual(move.state, 'waiting', "Wrong state in 'To consume line' of manufacturing order.") - # Check quantity of consume line with product D. - self.assertEqual(move.product_uom_qty, 20, "Wrong product quantity in 'To consume line' of manufacturing order.") # <><><><><><><><><><><><><><><><><><><><><><> # Manufacturing order for product D (20 unit).