From 7413ddd4e04846085b482cc0364486e503091a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 30 Aug 2021 00:27:13 +0200 Subject: [PATCH] Provide digits from unit of measure issue10677 review365801002 --- asset.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/asset.py b/asset.py index 258cb6c854..00f610a18d 100644 --- a/asset.py +++ b/asset.py @@ -99,22 +99,20 @@ class Asset(Workflow, ModelSQL, ModelView): required=True) currency = fields.Function(fields.Many2One('currency.currency', 'Currency'), 'on_change_with_currency') - quantity = fields.Float('Quantity', - digits=(16, Eval('unit_digits', 2)), + quantity = fields.Float( + "Quantity", digits='unit', states={ 'readonly': (Bool(Eval('supplier_invoice_line', 1)) | Eval('lines', [0]) | (Eval('state') != 'draft')), }, - depends=['state', 'unit_digits']) + depends=['state']) unit = fields.Many2One('product.uom', 'Unit', states={ 'readonly': (Bool(Eval('product')) | (Eval('state') != 'draft')), }, depends=['state']) - unit_digits = fields.Function(fields.Integer('Unit Digits'), - 'on_change_with_unit_digits') value = Monetary( "Value", currency='currency', digits='currency', states={ @@ -358,12 +356,6 @@ class Asset(Workflow, ModelSQL, ModelView): return None return self.product.default_uom.id - @fields.depends('unit') - def on_change_with_unit_digits(self, name=None): - if not self.unit: - return 2 - return self.unit.digits - @fields.depends('end_date', 'product', 'start_date') def on_change_with_end_date(self): if (all(getattr(self, k, None) for k in ('product', 'start_date'))