From 7cc8420ea0cbd4de367bd36ab8c778fe51e38d96 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 2 Jun 2017 11:17:38 +0200 Subject: [PATCH] [FIX] product_extended: workcenter cost - Create a work center with a capacity of 1, an efficiency factor of 100% and a cost per hour of 40$ - Create a routing with two operations: one with a fixed duration of 30:00 minutes (OP1) and another with a duration computed on real time but with a default of 30:00 minutes (OP2) - Create a component with UOM "m" and a cost of 10$ - Create a finished product with an associated BoM - The BoM has a first line with 0.8m of component in the OP1 and a second line with 0.4m of component in the OP2 - Activate the Compute from BoM option on the finished product - The proposed cost is 32$ Expected cost: 52$ (30 minutes @40$/hour + 30 minutes @40$/hour + 1,2m @10$/m) We divide the WC cost by the number of operations, which does not make sense. opw-741032 --- addons/product_extended/models/product.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/product_extended/models/product.py b/addons/product_extended/models/product.py index 11a7bdc07ef..e2cf9ff3684 100644 --- a/addons/product_extended/models/product.py +++ b/addons/product_extended/models/product.py @@ -35,7 +35,6 @@ class ProductProduct(models.Model): def _calc_price(self, bom): price = 0.0 - workcenter_cost = 0.0 result, result2 = bom.explode(self, 1) for sbom, sbom_data in result2: if not sbom.attribute_value_ids: @@ -45,8 +44,7 @@ class ProductProduct(models.Model): total_cost = 0.0 for order in bom.routing_id.operation_ids: total_cost += (order.time_cycle_manual/60) * order.workcenter_id.costs_hour - workcenter_cost = total_cost / len(bom.routing_id.operation_ids) - price += bom.product_uom_id._compute_price(workcenter_cost, bom.product_id.uom_id) + price += bom.product_uom_id._compute_price(total_cost, bom.product_id.uom_id) # Convert on product UoM quantities if price > 0: price = bom.product_uom_id._compute_price(price / bom.product_qty, self.uom_id)