diff --git a/location.py b/location.py index cc185dd5c7..8d626935df 100644 --- a/location.py +++ b/location.py @@ -191,8 +191,12 @@ class Location(ModelSQL, ModelView): with Transaction().set_context(context): product = product_obj.browse(product_id) for location in self.browse(ids): - cost_values[location.id] = (Decimal(str(location.quantity)) - * product.cost_price) + # The date could be before the product creation + if not isinstance(product.cost_price, Decimal): + cost_values[location.id] = None + else: + cost_values[location.id] = (Decimal(str(location.quantity)) + * product.cost_price) return cost_values def _set_warehouse_parent(self, locations): diff --git a/product.py b/product.py index f3d36d71b1..6e01df60eb 100644 --- a/product.py +++ b/product.py @@ -164,8 +164,12 @@ class Product(ModelSQL, ModelView): context['_datetime'] = trans_context['stock_date_end'] with Transaction().set_context(context): for product in self.browse(ids): - cost_values[product.id] = (Decimal(str(product.quantity)) - * product.cost_price) + # The date could be before the product creation + if not isinstance(product.cost_price, Decimal): + cost_values[product.id] = None + else: + cost_values[product.id] = (Decimal(str(product.quantity)) + * product.cost_price) return cost_values def products_by_location(self, location_ids, product_ids=None,