changeset 74a7122545ca in modules/sale:default
details: https://hg.tryton.org/modules/sale?cmd=changeset&node=74a7122545ca
description:
Provide digits from unit of measure
issue10677
review365801002
diffstat:
sale.fodt | 2 +-
sale.py | 23 +++++------------------
2 files changed, 6 insertions(+), 19 deletions(-)
diffs (75 lines):
diff -r 67261751bbc3 -r 74a7122545ca sale.fodt
--- a/sale.fodt Sat Aug 21 09:09:56 2021 +0200
+++ b/sale.fodt Mon Aug 30 00:27:13 2021 +0200
@@ -620,7 +620,7 @@
<text:p text:style-name="P21"><text:placeholder
text:placeholder-type="text"></if></text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Table1.D5" office:value-type="string">
- <text:p text:style-name="P12"><text:placeholder
text:placeholder-type="text"><(format_number(line.quantity, sale.party.lang,
digits=line.unit_digits) + (line.unit and (' ' + line.unit.symbol) or
'')) or ''></text:placeholder></text:p>
+ <text:p text:style-name="P12"><text:placeholder
text:placeholder-type="text"><(format_number(line.quantity, sale.party.lang,
digits=line.unit.digits if line.unit else None) + (line.unit and (' '
+ line.unit.symbol) or '')) or
''></text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Table1.D5" office:value-type="string">
<text:p text:style-name="P13"><text:placeholder
text:placeholder-type="text"><format_currency(line.unit_price,
sale.party.lang, sale.currency,
digits=line.__class__.unit_price.digits[1])></text:placeholder></text:p>
diff -r 67261751bbc3 -r 74a7122545ca sale.py
--- a/sale.py Sat Aug 21 09:09:56 2021 +0200
+++ b/sale.py Mon Aug 30 00:27:13 2021 +0200
@@ -1044,20 +1044,20 @@
'readonly': Eval('sale_state') != 'draft',
},
depends=['sale_state'])
- quantity = fields.Float('Quantity',
- digits=(16, Eval('unit_digits', 2)),
+ quantity = fields.Float(
+ "Quantity", digits='unit',
states={
'invisible': Eval('type') != 'line',
'required': Eval('type') == 'line',
'readonly': Eval('sale_state') != 'draft',
},
- depends=['type', 'unit_digits', 'sale_state'])
+ depends=['type', 'sale_state'])
actual_quantity = fields.Float(
- "Actual Quantity", digits=(16, Eval('unit_digits', 2)), readonly=True,
+ "Actual Quantity", digits='unit', readonly=True,
states={
'invisible': Eval('type') != 'line',
},
- depends=['unit_digits', 'type'])
+ depends=['type'])
unit = fields.Many2One('product.uom', 'Unit', ondelete='RESTRICT',
states={
'required': Bool(Eval('product')),
@@ -1070,8 +1070,6 @@
('category', '!=', -1)),
],
depends=['product', 'type', 'product_uom_category', 'sale_state'])
- unit_digits = fields.Function(fields.Integer('Unit Digits'),
- 'on_change_with_unit_digits')
product = fields.Many2One('product.product', 'Product',
ondelete='RESTRICT',
domain=[
@@ -1183,16 +1181,6 @@
def default_type():
return 'line'
- @staticmethod
- def default_unit_digits():
- return 2
-
- @fields.depends('unit')
- def on_change_with_unit_digits(self, name=None):
- if self.unit:
- return self.unit.digits
- return 2
-
@property
def _move_remaining_quantity(self):
"Compute the remaining quantity to ship"
@@ -1287,7 +1275,6 @@
category = self.product.sale_uom.category
if not self.unit or self.unit.category != category:
self.unit = self.product.sale_uom
- self.unit_digits = self.product.sale_uom.digits
self.unit_price = self.compute_unit_price()