From f7f5d9cf25f83ce2c17d632518399ca4b5de50f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 5 Dec 2020 11:51:29 +0100 Subject: [PATCH] Add digits to cost value of location issue9877 review320451002 --- location.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/location.py b/location.py index e43f303b38..88187f4110 100644 --- a/location.py +++ b/location.py @@ -16,6 +16,8 @@ from trytond.pool import Pool, PoolMeta from trytond.tools import grouped_slice from trytond.tools.multivalue import migrate_property +from trytond.modules.product import price_digits, round_price + from .exceptions import LocationValidationError @@ -164,8 +166,9 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView): fields.Float('Forecast Quantity', help="The amount of stock expected to be in the location."), 'get_quantity', searcher='search_quantity') - cost_value = fields.Function(fields.Numeric('Cost Value', - help="The value of the stock in the location."), + cost_value = fields.Function(fields.Numeric( + "Cost Value", digits=price_digits, + help="The value of the stock in the location."), 'get_cost_value') @classmethod @@ -471,7 +474,7 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView): # The template may have more than one product if cost_price is not None: for location in locations: - cost_values[location.id] = ( + cost_values[location.id] = round_price( Decimal(str(location.quantity)) * cost_price) return cost_values