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

        issue10598
        review338511002
diffstat:

 account.py                     |  15 +++++----------
 view/invoice_deferred_form.xml |   2 +-
 view/invoice_deferred_list.xml |   2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)

diffs (70 lines):

diff -r 39fe6f6c690e -r bc9a07071482 account.py
--- a/account.py        Mon Jul 12 22:56:26 2021 +0200
+++ b/account.py        Sat Aug 21 09:09:55 2021 +0200
@@ -9,6 +9,8 @@
 from trytond.transaction import Transaction
 from trytond.wizard import Wizard, StateTransition
 
+from trytond.modules.currency.fields import Monetary
+
 
 class Configuration(metaclass=PoolMeta):
     __name__ = 'account.configuration'
@@ -89,9 +91,9 @@
             ('invoice.company', '=', Eval('company', -1)),
             ],
         states=_states, depends=_depends + ['type', 'company'])
-    amount = fields.Numeric(
-        "Amount", digits=(16, Eval('currency_digits', 2)), required=True,
-        states=_states, depends=_depends + ['currency_digits'])
+    amount = Monetary(
+        "Amount", currency='currency', digits='currency', required=True,
+        states=_states, depends=_depends)
     start_date = fields.Date(
         "Start Date", required=True,
         domain=[
@@ -117,8 +119,6 @@
 
     currency = fields.Function(fields.Many2One(
             'currency.currency', "Currency"), 'on_change_with_currency')
-    currency_digits = fields.Function(fields.Integer("Currency Digits"),
-        'on_change_with_currency_digits')
 
     del _states, _depends
 
@@ -189,11 +189,6 @@
         if self.company:
             return self.company.currency.id
 
-    @fields.depends('company')
-    def on_change_with_currency_digits(self, name=None):
-        if self.company:
-            return self.company.currency.digits
-
     @classmethod
     @ModelView.button
     @Workflow.transition('running')
diff -r 39fe6f6c690e -r bc9a07071482 view/invoice_deferred_form.xml
--- a/view/invoice_deferred_form.xml    Mon Jul 12 22:56:26 2021 +0200
+++ b/view/invoice_deferred_form.xml    Sat Aug 21 09:09:55 2021 +0200
@@ -10,7 +10,7 @@
     <label name="journal"/>
     <field name="journal"/>
     <label name="amount"/>
-    <field name="amount" symbol="currency"/>
+    <field name="amount"/>
 
     <label name="start_date"/>
     <field name="start_date"/>
diff -r 39fe6f6c690e -r bc9a07071482 view/invoice_deferred_list.xml
--- a/view/invoice_deferred_list.xml    Mon Jul 12 22:56:26 2021 +0200
+++ b/view/invoice_deferred_list.xml    Sat Aug 21 09:09:55 2021 +0200
@@ -6,7 +6,7 @@
     <field name="invoice_line" expand="1"/>
     <field name="start_date"/>
     <field name="end_date"/>
-    <field name="amount" symbol="currency"/>
+    <field name="amount"/>
     <field name="state"/>
     <button name="run"/>
 </tree>

Reply via email to