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

        issue10598
        review338511002
diffstat:

 view/work_form.xml          |   6 +++---
 view/work_list.xml          |   6 +++---
 view/work_list_children.xml |   4 ++--
 view/work_tree.xml          |   6 +++---
 work.py                     |  33 +++++++++------------------------
 5 files changed, 20 insertions(+), 35 deletions(-)

diffs (124 lines):

diff -r 2c2352f5b135 -r dcbe67824a63 view/work_form.xml
--- a/view/work_form.xml        Sun Jul 04 17:54:47 2021 +0200
+++ b/view/work_form.xml        Sat Aug 21 09:09:56 2021 +0200
@@ -7,15 +7,15 @@
         <label name="product"/>
         <field name="product"/>
         <label name="list_price"/>
-        <field name="list_price" symbol="currency"/>
+        <field name="list_price"/>
         <newline/>
     </xpath>
     <xpath 
expr="/form/notebook/page[@id='general']/field[@name='total_effort']"
         position="after">
         <newline/>
         <label name="cost"/>
-        <field name="cost" symbol="currency"/>
+        <field name="cost"/>
         <label name="revenue"/>
-        <field name="revenue" symbol="currency"/>
+        <field name="revenue"/>
     </xpath>
 </data>
diff -r 2c2352f5b135 -r dcbe67824a63 view/work_list.xml
--- a/view/work_list.xml        Sun Jul 04 17:54:47 2021 +0200
+++ b/view/work_list.xml        Sat Aug 21 09:09:56 2021 +0200
@@ -4,8 +4,8 @@
 <data>
     <xpath expr="/tree/field[@name='total_effort']" position="after">
         <field name="product"/>
-        <field name="list_price" symbol="currency"/>
-        <field name="revenue" symbol="currency"/>
-        <field name="cost" symbol="currency"/>
+        <field name="list_price"/>
+        <field name="revenue"/>
+        <field name="cost"/>
     </xpath>
 </data>
diff -r 2c2352f5b135 -r dcbe67824a63 view/work_list_children.xml
--- a/view/work_list_children.xml       Sun Jul 04 17:54:47 2021 +0200
+++ b/view/work_list_children.xml       Sat Aug 21 09:09:56 2021 +0200
@@ -4,7 +4,7 @@
 <data>
     <xpath expr="/tree/field[@name='total_effort']" position="after">
         <field name="product"/>
-        <field name="list_price" symbol="currency"/>
-        <field name="cost" symbol="currency"/>
+        <field name="list_price"/>
+        <field name="cost"/>
     </xpath>
 </data>
diff -r 2c2352f5b135 -r dcbe67824a63 view/work_tree.xml
--- a/view/work_tree.xml        Sun Jul 04 17:54:47 2021 +0200
+++ b/view/work_tree.xml        Sat Aug 21 09:09:56 2021 +0200
@@ -4,8 +4,8 @@
 <data>
     <xpath expr="/tree/field[@name='total_effort']" position="after">
         <field name="product"/>
-        <field name="list_price" symbol="currency"/>
-        <field name="revenue" symbol="currency"/>
-        <field name="cost" symbol="currency"/>
+        <field name="list_price"/>
+        <field name="revenue"/>
+        <field name="cost"/>
     </xpath>
 </data>
diff -r 2c2352f5b135 -r dcbe67824a63 work.py
--- a/work.py   Sun Jul 04 17:54:47 2021 +0200
+++ b/work.py   Sat Aug 21 09:09:56 2021 +0200
@@ -12,6 +12,7 @@
 from trytond.pool import Pool, PoolMeta
 from trytond.tools import reduce_ids, grouped_slice
 
+from trytond.modules.currency.fields import Monetary
 from trytond.modules.product import price_digits, round_price
 
 
@@ -25,17 +26,16 @@
             'company': Eval('company', -1),
             },
         depends=['company'])
-    list_price = fields.Numeric('List Price', digits=price_digits)
-    revenue = fields.Function(fields.Numeric('Revenue',
-            digits=(16, Eval('currency_digits', 2)),
-            depends=['currency_digits']), 'get_total')
-    cost = fields.Function(fields.Numeric('Cost',
-            digits=(16, Eval('currency_digits', 2)),
-            depends=['currency_digits']), 'get_total')
+    list_price = Monetary(
+        "List Price", currency='currency', digits=price_digits)
+    revenue = fields.Function(Monetary(
+            "Revenue", currency='currency', digits='currency'),
+        'get_total')
+    cost = fields.Function(Monetary(
+            "Cost", currency='currency', digits='currency'),
+        'get_total')
     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')
 
     @classmethod
     def __setup__(cls):
@@ -175,21 +175,6 @@
         if self.company:
             return self.company.currency.id
 
-    @fields.depends('currency')
-    def on_change_with_currency_digits(self, name=None):
-        if self.currency:
-            return self.currency.digits
-        return 2
-
-    @staticmethod
-    def default_currency_digits():
-        Company = Pool().get('company.company')
-        company = Transaction().context.get('company')
-        if company:
-            company = Company(company)
-            return company.currency.digits
-        return 2
-
     @fields.depends('product', 'company')
     def on_change_product(self):
         pool = Pool()

Reply via email to