[FIX] mrp: compute operation time in bom report
Current behavior: When you use a workcenter with start and stop time in a BoM the start/stop time is applied for each quantity in the BoM report and workorder. For example if you have 3 quantities the start/stop time will be applied 3 times. Steps to reproduce: - Create a product to manufacture (With atleast 1 operation) - Create a workcenter that has positive Start/Stop time values - Start and stop time are multiplied by the quantity in the BoM report opw-2779381 closes odoo/odoo#86321 X-original-commit: 3bb32903f90fa86eb28b4551b07a5817f8e9f528 Signed-off-by: Adrien Widart <awt@odoo.com> Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user