changeset ddcef08f5934 in modules/account_statement_rule:default
details: 
https://hg.tryton.org/modules/account_statement_rule?cmd=changeset&node=ddcef08f5934
description:
        Add monetary field

        issue10598
        review338511002
diffstat:

 account.py |  27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diffs (66 lines):

diff -r 5deaa442f09a -r ddcef08f5934 account.py
--- a/account.py        Tue Aug 17 10:10:20 2021 +0200
+++ b/account.py        Sat Aug 21 09:09:55 2021 +0200
@@ -13,6 +13,8 @@
 from trytond.tools import decistmt
 from trytond.transaction import Transaction
 
+from trytond.modules.currency.fields import Monetary
+
 
 class Statement(metaclass=PoolMeta):
     __name__ = 'account.statement'
@@ -75,26 +77,24 @@
                 ()),
             ],
         depends=['company'])
-    amount_low = fields.Numeric(
-        "Amount Low",
-        digits=(16, Eval('currency_digits', 2)),
+    amount_low = Monetary(
+        "Amount Low", currency='currency', digits='currency',
         domain=[If(Eval('amount_high'),
                 ['OR',
                     ('amount_low', '=', None),
                     ('amount_low', '<=', Eval('amount_high')),
                     ],
                 [])],
-        depends=['currency_digits', 'amount_high'])
-    amount_high = fields.Numeric(
-        "Amount High",
-        digits=(16, Eval('currency_digits', 2)),
+        depends=['amount_high'])
+    amount_high = Monetary(
+        "Amount High", currency='currency', digits='currency',
         domain=[If(Eval('amount_low'),
                 ['OR',
                     ('amount_high', '=', None),
                     ('amount_high', '>=', Eval('amount_low')),
                     ],
                 [])],
-        depends=['currency_digits', 'amount_low'])
+        depends=['amount_low'])
     description = fields.Char("Description",
         help="The regular expression the description is searched with.\n"
         "It may define the groups named:\n"
@@ -105,15 +105,14 @@
     lines = fields.One2Many(
         'account.statement.rule.line', 'rule', "Lines")
 
-    currency_digits = fields.Function(
-        fields.Integer("Currency Digits"),
-        'on_change_with_currency_digits')
+    currency = fields.Function(fields.Many2One(
+            'currency.currency', "Currency"),
+        'on_change_with_currency')
 
     @fields.depends('journal')
-    def on_change_with_currency_digits(self, name=None):
+    def on_change_with_currency(self, name=None):
         if self.journal:
-            return self.journal.currency.digits
-        return None
+            return self.journal.currency.id
 
     def match(self, origin):
         keywords = {}

Reply via email to