Add monetary field
issue10598 review338511002
This commit is contained in:
1 parent
2f0912e7ac
commit
119a3a82fd
4 files changed
+6
-13
No files matched your search
@@ -14,6 +14,7 @@ from trytond.sendmail import sendmail_transactional
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
from trytond.modules.company.model import CompanyValueMixin
|
||||
from trytond.modules.currency.fields import Monetary
|
||||
|
||||
|
||||
class Configuration(metaclass=PoolMeta):
|
||||
@@ -73,9 +74,9 @@ class GiftCard(ModelSQL, ModelView):
|
||||
'company': Eval('company', -1),
|
||||
},
|
||||
states=_states, depends=_depends + ['company'])
|
||||
value = fields.Numeric(
|
||||
"Value", digits=(16, Eval('currency_digits', 2)), required=True,
|
||||
states=_states, depends=_depends + ['currency_digits'])
|
||||
value = Monetary(
|
||||
"Value", currency='currency', digits='currency', required=True,
|
||||
states=_states, depends=_depends)
|
||||
currency = fields.Many2One(
|
||||
'currency.currency', "Currency", required=True,
|
||||
states=_states, depends=_depends)
|
||||
@@ -85,9 +86,6 @@ class GiftCard(ModelSQL, ModelView):
|
||||
spent_on = fields.Reference(
|
||||
"Spent On", selection='get_spent_on', select=True, readonly=True)
|
||||
|
||||
currency_digits = fields.Function(
|
||||
fields.Integer("Currency Digits"), 'on_change_with_currency_digits')
|
||||
|
||||
del _states
|
||||
del _depends
|
||||
|
||||
@@ -107,11 +105,6 @@ class GiftCard(ModelSQL, ModelView):
|
||||
def default_company(cls):
|
||||
return Transaction().context.get('company')
|
||||
|
||||
@fields.depends('currency')
|
||||
def on_change_with_currency_digits(self, name=None):
|
||||
if self.currency:
|
||||
return self.currency.digits
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
return ['sale.line', 'stock.move']
|
||||
|
||||
@@ -4,6 +4,7 @@ depends:
|
||||
account
|
||||
account_invoice
|
||||
company
|
||||
currency
|
||||
ir
|
||||
product
|
||||
sale
|
||||
|
||||
@@ -12,7 +12,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<newline/>
|
||||
|
||||
<label name="value"/>
|
||||
<field name="value"/>
|
||||
<field name="value" symbol=""/>
|
||||
<label name="currency"/>
|
||||
<field name="currency"/>
|
||||
|
||||
|
||||
@@ -5,6 +5,5 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="number" expand="2"/>
|
||||
<field name="product"/>
|
||||
<field name="value" expand="1"/>
|
||||
<field name="currency"/>
|
||||
<field name="company"/>
|
||||
</tree>
|
||||
Reference in new issue
Block a user