diff --git a/addons/mrp/report/mrp_report_bom_structure.py b/addons/mrp/report/mrp_report_bom_structure.py index 9786392cddb..91d66ae2dde 100644 --- a/addons/mrp/report/mrp_report_bom_structure.py +++ b/addons/mrp/report/mrp_report_bom_structure.py @@ -221,7 +221,7 @@ class ReportBomStructure(models.AbstractModel): if operation._skip_operation_line(product): continue operation_cycle = float_round(qty / operation.workcenter_id.capacity, precision_rounding=1, rounding_method='UP') - duration_expected = operation_cycle * (operation.time_cycle + (operation.workcenter_id.time_stop + operation.workcenter_id.time_start)) + duration_expected = (operation_cycle * operation.time_cycle * 100.0 / operation.workcenter_id.time_efficiency) + (operation.workcenter_id.time_stop + operation.workcenter_id.time_start) total = ((duration_expected / 60.0) * operation.workcenter_id.costs_hour) operations.append({ 'level': level or 0, diff --git a/addons/mrp/tests/test_bom.py b/addons/mrp/tests/test_bom.py index 8fc39cff403..81f12e785a4 100644 --- a/addons/mrp/tests/test_bom.py +++ b/addons/mrp/tests/test_bom.py @@ -580,9 +580,9 @@ class TestBoM(TestMrpCommon): # TEST CHEESE BOM STRUCTURE VALUE WITH BOM QUANTITY report_values = self.env['report.mrp.report_bom_structure']._get_report_data(bom_id=bom_cheese_cake.id, searchQty=60, searchVariant=False) #Operation time = 15 min * 60 + time_start + time_stop = 925 - self.assertEqual(report_values['lines']['operations_time'], 2400.0, 'Operation time should be the same for 1 unit or for the batch') - # Operation cost is the sum of operation line : 10 min * 60 * 10€/hr = 100€ + 30min * 60 * 20€/hr = 700€ - self.assertEqual(float_compare(report_values['lines']['operations_cost'], 700, precision_digits=2), 0) + self.assertEqual(report_values['lines']['operations_time'], 925.0, 'Operation time should be the same for 1 unit or for the batch') + # Operation cost is the sum of operation line : (60 * 10)/60 * 10€ + (10 + 15 + 60 * 5)/60 * 20€ = 208,33€ + self.assertEqual(float_compare(report_values['lines']['operations_cost'], 208.33, precision_digits=2), 0) for component_line in report_values['lines']['components']: # standard price * bom line quantity * current quantity / bom finished product quantity @@ -593,8 +593,8 @@ class TestBoM(TestMrpCommon): # 5.4 kg of crumble at the cost of a batch. crumble_cost = self.env['report.mrp.report_bom_structure']._get_report_data(bom_id=bom_crumble.id, searchQty=5.4, searchVariant=False)['lines']['total'] self.assertEqual(float_compare(component_line['total'], crumble_cost, precision_digits=2), 0) - # total price = Cream (15.51€) + crumble_cost (34.63 €) + operation_cost(700€) = 750.14€ - self.assertEqual(float_compare(report_values['lines']['total'], 715.51 + crumble_cost, precision_digits=2), 0, 'Product Bom Price is not correct') + # total price = Cream (15.51€) + crumble_cost (34.63 €) + operation_cost(208,33) = 258.47€ + self.assertEqual(float_compare(report_values['lines']['total'], 258.47, precision_digits=2), 0, 'Product Bom Price is not correct') def test_bom_report_dozens(self): """ Simulate a drawer bom with dozens as bom units