From fd17d80efdd5e01b52475bb85883b4fdaa11d8b4 Mon Sep 17 00:00:00 2001 From: "Walid HANNICHE (waha)" Date: Thu, 20 Oct 2022 21:35:31 +0000 Subject: [PATCH] [FIX] mrp_account: include time effeciency in bom price Steps to reproduce: - set time effeciency of a workcenter to less than 100 - on a product page with a BoM using that workcenter - for the cost click on compute price from BoM Bug: workcenter effeciency is not taken into consideration Fix: included time_effeciency in computing the expected duration addepted tests to take it into consideration aswell opw-3033672 closes odoo/odoo#104566 X-original-commit: 1dcd9dbef0a5e6d9bd2c5e52a42cff9aec98f1d0 Signed-off-by: Adrien Widart Signed-off-by: Walid Hanniche (waha) --- addons/mrp_account/models/product.py | 2 +- addons/mrp_account/tests/test_bom_price.py | 30 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/addons/mrp_account/models/product.py b/addons/mrp_account/models/product.py index 98f0ee2bfba..06471524d8c 100644 --- a/addons/mrp_account/models/product.py +++ b/addons/mrp_account/models/product.py @@ -79,7 +79,7 @@ class ProductProduct(models.Model): duration_expected = ( opt.workcenter_id.time_start + opt.workcenter_id.time_stop + - opt.time_cycle) + opt.time_cycle * 100 / opt.workcenter_id.time_efficiency) total += (duration_expected / 60) * opt.workcenter_id.costs_hour for line in bom.bom_line_ids: diff --git a/addons/mrp_account/tests/test_bom_price.py b/addons/mrp_account/tests/test_bom_price.py index dff1f023b75..8ea43a4ac4a 100644 --- a/addons/mrp_account/tests/test_bom_price.py +++ b/addons/mrp_account/tests/test_bom_price.py @@ -111,11 +111,11 @@ class TestBomPrice(common.TransactionCase): """Test calcuation of bom cost with operations.""" workcenter_from1 = Form(self.env['mrp.workcenter']) workcenter_from1.name = 'Workcenter' - workcenter_from1.time_efficiency = 100 + workcenter_from1.time_efficiency = 80 workcenter_from1.default_capacity = 2 workcenter_from1.oee_target = 100 - workcenter_from1.time_start = 0 - workcenter_from1.time_stop = 0 + workcenter_from1.time_start = 15 + workcenter_from1.time_stop = 15 workcenter_from1.costs_hour = 100 workcenter_1 = workcenter_from1.save() @@ -175,11 +175,11 @@ class TestBomPrice(common.TransactionCase): # Dinning Table Operation Cost(1 Unit) # ----------------------------------------------------------------- # Operation cost calculate for 1 units - # Cutting (20 / 60) * 100 = 33.33 - # Drilling (25 / 60) * 100 = 41.67 - # Fitting (30 / 60) * 100 = 50.00 + # Cutting (15 + 15 + (20 * 100/80) / 60) * 100 = 91.67 + # Drilling (15 + 15 + (25 * 100/80) / 60) * 100 = 102.08 + # Fitting (15 + 15 + (30 * 100/80) / 60) * 100 = 112.50 # ---------------------------------------- - # Operation Cost 1 unit = 125 + # Operation Cost 1 unit = 306.25 # ----------------------------------------------------------------- @@ -187,21 +187,21 @@ class TestBomPrice(common.TransactionCase): # Table Head Operation Cost (1 Dozen) # -------------------------------------------------------------------------- # Operation cost calculate for 1 dozens - # Cutting (20 * 1 / 60) * 100 = 33,33 - # Drilling (25 * 1 / 60) * 100 = 41,67 - # Fitting (30 * 1 / 60) * 100 = 50 + # Cutting (15 + 15 + (20 * 1 * 100/80) / 60) * 100 = 91.67 + # Drilling (15 + 15 + (25 * 1 * 100/80) / 60) * 100 = 102.08 + # Fitting (15 + 15 + (30 * 1 * 100/80) / 60) * 100 = 112.50 # ---------------------------------------- - # Operation Cost 1 dozen (125 per dozen) and 10.42 for 1 Unit + # Operation Cost 1 dozen (306.25 per dozen) and 25.52 for 1 Unit # -------------------------------------------------------------------------- self.assertEqual(self.dining_table.standard_price, 1000, "Initial price of the Product should be 1000") self.dining_table.button_bom_cost() - # Total cost of Dining Table = (550) + Total cost of operations (125) = 675.0 - self.assertEqual(float_round(self.dining_table.standard_price, precision_digits=2), 675.0, "After computing price from BoM price should be 612.5") + # Total cost of Dining Table = (550) + Total cost of operations (306.25) = 856.25 + self.assertEqual(float_round(self.dining_table.standard_price, precision_digits=2), 856.25, "After computing price from BoM price should be 856.25") self.Product.browse([self.dining_table.id, self.table_head.id]).action_bom_cost() - # Total cost of Dining Table = (718.75) + Total cost of all operations (125 + 10.42) = 854.17 - self.assertEqual(float_compare(self.dining_table.standard_price, 854.17, precision_digits=2), 0, "After computing price from BoM price should be 786.46") + # Total cost of Dining Table = (718.75) + Total cost of all operations (306.25 + 25.52) = 1050.52 + self.assertEqual(float_compare(self.dining_table.standard_price, 1050.52, precision_digits=2), 0, "After computing price from BoM price should be 1050.52") def test_02_compute_byproduct_price(self): """Test BoM cost when byproducts with cost share"""