Define product variable to raise error when cost price expression is not a Decimal

The product variable is used to format the error message but also as for
50bf49b7b031 it may be empty.

Closes #14062
This commit is contained in:
Cédric Krier
2025-06-10 18:12:43 +02:00
parent 4b07c0d666
commit d1b33c2dc0
+2 -1
View File
@@ -1317,11 +1317,12 @@ class CostPriceRevision(ModelSQL, ModifyCostPriceStart):
product=product.rec_name if product else '',
exception=exception)) from exception
if not isinstance(amount, Decimal):
product = self.product or self.template
raise ProductCostPriceError(
gettext('stock.msg_invalid_cost_price_not_number',
value=amount,
cost_price=self.cost_price,
product=product.rec_name))
product=product.rec_name if product else ''))
return amount
@classmethod