From 7190a659e77287444f9c04ff022d8a55d1146d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 11 Apr 2022 23:44:19 +0200 Subject: [PATCH] Use format_number_symbol for quantity in error message issue11376 review395651002 --- message.xml | 2 +- sale.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/message.xml b/message.xml index 70d2af7338..f2aa7db637 100644 --- a/message.xml +++ b/message.xml @@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. --> - The forcast quantity (%(forecast_quantity)s%(default_uom)s) for line "%(line)s" is lower than its quantity (%(quantity)s%(unit)s). + The forcast quantity (%(forecast_quantity)s) for line "%(line)s" is lower than its quantity (%(quantity)s). The forecast quantity (%(forecast_quantity)s) of product "%(product)s" is lower than the quantity (%(quantity)s). diff --git a/sale.py b/sale.py index 6bc3b165d2..056d554531 100644 --- a/sale.py +++ b/sale.py @@ -64,6 +64,7 @@ class Sale(metaclass=PoolMeta): Group = pool.get('res.group') User = pool.get('res.user') ModelData = pool.get('ir.model.data') + Lang = pool.get('ir.lang') Line = pool.get('sale.line') Warning = pool.get('res.user.warning') @@ -123,6 +124,7 @@ class Sale(metaclass=PoolMeta): with Transaction().set_context(company=self.company.id): today = Date.today() + lang = Lang.get() sale_date = self.sale_date or today product_ids = {l.product.id for l in filter(filter_line, self.lines)} product_ids = list(product_ids) @@ -169,10 +171,11 @@ class Sale(metaclass=PoolMeta): next_supply_date = self._stock_quantity_next_supply_date(product) message_values = { 'line': line.rec_name, - 'forecast_quantity': quantities[product], - 'default_uom': product.default_uom.symbol, - 'quantity': line.quantity, - 'unit': line.unit.symbol, + 'forecast_quantity': lang.format_number_symbol( + quantities[product], product.default_uom, + product.default_uom.digits), + 'quantity': lang.format_number_symbol( + line.quantity, line.unit, line.unit.digits), } if (quantities[product] < quantity and sale_date < next_supply_date):