mrp_average_cost: avoid crash on bad data

This commit is contained in:
Alexis de Lattre
2024-06-25 01:10:51 +02:00
parent 9367f7006e
commit 8bd83b0975

View File

@@ -180,7 +180,7 @@ class MrpProduction(models.Model):
def _compute_extra_cost(self):
for prod in self:
bom = prod.bom_id
if bom and bom.type == 'normal':
if bom and bom.type == 'normal' and bom.product_uom_id.category_id == prod.product_uom_id.category_id:
extra_cost_bom_qty_uom = bom.extra_cost + bom.total_labour_cost
extra_cost_per_unit_in_prod_uom = 0
qty_prod_uom = bom.product_uom_id._compute_quantity(bom.product_qty, prod.product_uom_id)