From d1b33c2dc04bea2958a7a5ace45c01cd0e5695d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 10 Jun 2025 18:12:43 +0200 Subject: [PATCH] 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 --- modules/stock/product.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/stock/product.py b/modules/stock/product.py index 90347f3e2a..a9869baa7a 100644 --- a/modules/stock/product.py +++ b/modules/stock/product.py @@ -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