changeset 788f0b59e954 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=788f0b59e954
description:
Provide digits from unit of measure
issue10677
review365801002
diffstat:
purchase.fodt | 2 +-
purchase.py | 19 +++++--------------
2 files changed, 6 insertions(+), 15 deletions(-)
diffs (71 lines):
diff -r 0d680014600a -r 788f0b59e954 purchase.fodt
--- a/purchase.fodt Sat Aug 21 09:09:56 2021 +0200
+++ b/purchase.fodt Mon Aug 30 00:27:13 2021 +0200
@@ -674,7 +674,7 @@
<text:p text:style-name="P24"><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,
purchase.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,
purchase.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,
purchase.party.lang, purchase.currency,
digits=line.__class__.unit_price.digits[1])></text:placeholder></text:p>
diff -r 0d680014600a -r 788f0b59e954 purchase.py
--- a/purchase.py Sat Aug 21 09:09:56 2021 +0200
+++ b/purchase.py Mon Aug 30 00:27:13 2021 +0200
@@ -1011,20 +1011,20 @@
'readonly': Eval('purchase_state') != 'draft',
},
depends=['purchase_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('purchase_state') != 'draft',
},
- depends=['unit_digits', 'type', 'purchase_state'])
+ depends=['type', 'purchase_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={
@@ -1038,8 +1038,6 @@
('category', '!=', -1)),
],
depends=['product', 'type', 'product_uom_category', 'purchase_state'])
- unit_digits = fields.Function(fields.Integer('Unit Digits'),
- 'on_change_with_unit_digits')
product = fields.Many2One('product.product', 'Product',
ondelete='RESTRICT',
domain=[
@@ -1233,12 +1231,6 @@
return True
return False
- @fields.depends('unit')
- def on_change_with_unit_digits(self, name=None):
- if self.unit:
- return self.unit.digits
- return 2
-
def _get_tax_rule_pattern(self):
'''
Get tax rule pattern
@@ -1296,7 +1288,6 @@
category = self.product.purchase_uom.category
if not self.unit or self.unit.category != category:
self.unit = self.product.purchase_uom
- self.unit_digits = self.product.purchase_uom.digits
product_suppliers = list(self.product.product_suppliers_used(
**self._get_product_supplier_pattern()))