[FIX] product_extended: Compute from BoM

The price suggested thanks to the "Compute from BoM" button only takes
into account the price of the products listed in the BoM lines.

In v9, there was a "Recursive" option that provided the possibility to
compute the prices of all products implied in the BoM, recursively. This
option has been removed since it was leading to a "black box" behavior
that was unclear to the users.

However, limiting the price computation to the BoM lines only is too
restrictive since it doesn't even take into account the phantom BoMs.
By using the `explode` method, we have access to:
- all products not manufactured
- all products manufactured which are not kits (phantom BoM)

It means that the cost of manufactured products (not kits) should still
be computed before the product itself.

opw-697866
This commit is contained in:
Nicolas Martinelli
2017-01-13 13:25:00 +01:00
parent 11e99a0b53
commit 8fd6f85169
+3 -3
View File
@@ -36,11 +36,11 @@ class ProductProduct(models.Model):
def _calc_price(self, bom):
price = 0.0
workcenter_cost = 0.0
for sbom in bom.bom_line_ids:
my_qty = sbom.product_qty
result, result2 = bom.explode(self, 1)
for sbom, sbom_data in result2:
if not sbom.attribute_value_ids:
# No attribute_value_ids means the bom line is not variant specific
price += sbom.product_id.uom_id._compute_price(sbom.product_id.standard_price, sbom.product_uom_id) * my_qty
price += sbom.product_id.uom_id._compute_price(sbom.product_id.standard_price, sbom.product_uom_id) * sbom_data['qty']
if bom.routing_id:
total_cost = 0.0
for order in bom.routing_id.operation_ids: