Use PySON

This commit is contained in:
Cédric Krier committed 2010-01-20 10:57:08 +01:00
1 parent afe744f5ca
commit aaba43f53f
5 files changed
+187 -121

No files matched your search

+53 -20
View File
@@ -1,30 +1,63 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.pyson import Eval, Not, Equal
class FiscalYear(ModelSQL, ModelView):
_name = 'account.fiscalyear'
out_invoice_sequence = fields.Many2One('ir.sequence.strict',
'Customer Invoice Sequence', required=True,
domain=[('code', '=', 'account.invoice'),
['OR', "('company', '=', company)", ('company', '=', False)]],
context="{'code': 'account.invoice', 'company': company}")
domain=[
('code', '=', 'account.invoice'),
['OR',
('company', '=', Eval('company')),
('company', '=', False),
],
],
context={
'code': 'account.invoice',
'company': Eval('company'),
})
in_invoice_sequence = fields.Many2One('ir.sequence.strict',
'Supplier Invoice Sequence', required=True,
domain=[('code', '=', 'account.invoice'),
['OR', "('company', '=', company)", ('company', '=', False)]],
context="{'code': 'account.invoice', 'company': company}")
domain=[
('code', '=', 'account.invoice'),
['OR',
('company', '=', Eval('company')),
('company', '=', False),
],
],
context={
'code': 'account.invoice',
'company': Eval('company'),
})
out_credit_note_sequence = fields.Many2One('ir.sequence.strict',
'Customer Credit Note Sequence', required=True,
domain=[('code', '=', 'account.invoice'),
['OR', "('company', '=', company)", ('company', '=', False)]],
context="{'code': 'account.invoice', 'company': company}")
domain=[
('code', '=', 'account.invoice'),
['OR',
('company', '=', Eval('company')),
('company', '=', False),
],
],
context={
'code': 'account.invoice',
'company': Eval('company'),
})
in_credit_note_sequence = fields.Many2One('ir.sequence.strict',
'Supplier Credit Note Sequence', required=True,
domain=[('code', '=', 'account.invoice'),
['OR', "('company', '=', company)", ('company', '=', False)]],
context="{'code': 'account.invoice', 'company': company}")
domain=[
('code', '=', 'account.invoice'),
['OR',
('company', '=', Eval('company')),
('company', '=', False),
],
],
context={
'code': 'account.invoice',
'company': Eval('company'),
})
def __init__(self):
super(FiscalYear, self).__init__()
@@ -81,32 +114,32 @@ class Period(ModelSQL, ModelView):
domain=[('code', '=', 'account.invoice')],
context={'code': 'account.invoice'},
states={
'required': "type == 'standard'",
'invisible': "type != 'standard'",
'required': Equal(Eval('type'), 'standard'),
'invisible': Not(Equal(Eval('type'), 'standard')),
})
in_invoice_sequence = fields.Many2One('ir.sequence.strict',
'Supplier Invoice Sequence',
domain=[('code', '=', 'account.invoice')],
context={'code': 'account.invoice'},
states={
'required': "type == 'standard'",
'invisible': "type != 'standard'",
'required': Equal(Eval('type'), 'standard'),
'invisible': Not(Equal(Eval('type'), 'standard')),
})
out_credit_note_sequence = fields.Many2One('ir.sequence.strict',
'Customer Credit Note Sequence',
domain=[('code', '=', 'account.invoice')],
context={'code': 'account.invoice'},
states={
'required': "type == 'standard'",
'invisible': "type != 'standard'",
'required': Equal(Eval('type'), 'standard'),
'invisible': Not(Equal(Eval('type'), 'standard')),
})
in_credit_note_sequence = fields.Many2One('ir.sequence.strict',
'Supplier Credit Note Sequence',
domain=[('code', '=', 'account.invoice')],
context={'code': 'account.invoice'},
states={
'required': "type == 'standard'",
'invisible': "type != 'standard'",
'required': Equal(Eval('type'), 'standard'),
'invisible': Not(Equal(Eval('type'), 'standard')),
})
def __init__(self):
+115 -84
View File
@@ -5,11 +5,12 @@ from trytond.model import ModelWorkflow, ModelView, ModelSQL, fields
from trytond.report import Report
from trytond.wizard import Wizard
from trytond.backend import TableHandler, FIELDS
from trytond.pyson import In, If, Get, Eval, Not, Equal, Bool, Or, And
from decimal import Decimal
import base64
_STATES = {
'readonly': "state != 'draft'",
'readonly': Not(Equal(Eval('state'), 'draft')),
}
_TYPE = [
@@ -34,12 +35,14 @@ class Invoice(ModelWorkflow, ModelSQL, ModelView):
_order_name = 'number'
company = fields.Many2One('company.company', 'Company', required=True,
states=_STATES, select=1, domain=[
"('id', 'company' in context and '=' or '!=', " \
"context.get('company', 0))"])
('id', If(In('company', Eval('context', {})), '=', '!='),
Get(Eval('context', {}), 'company', 0)),
])
type = fields.Selection(_TYPE, 'Type', select=1, on_change=['type'],
required=True, states={
'readonly': "state != 'draft' or context.get('type', False)" \
" or (bool(lines) and bool(type))",
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
Bool(Get(Eval('context', {}), 'type')),
And(Bool(Eval('lines')), Bool(Eval('type')))),
})
type_name = fields.Function('get_type_name', type='char', string='Type')
number = fields.Char('Number', size=None, readonly=True, select=1)
@@ -54,8 +57,8 @@ class Invoice(ModelWorkflow, ModelSQL, ModelView):
], 'State', readonly=True)
invoice_date = fields.Date('Invoice Date',
states={
'readonly': "state in ('open', 'paid', 'cancel')",
'required': "state in ('open', 'paid')",
'readonly': In(Eval('state'), ['open', 'paid', 'cancel']),
'required': In(Eval('state'), ['open', 'paid']),
})
accounting_date = fields.Date('Accounting Date', states=_STATES)
party = fields.Many2One('party.party', 'Party', change_default=True,
@@ -64,10 +67,11 @@ class Invoice(ModelWorkflow, ModelSQL, ModelView):
party_lang = fields.Function('get_party_language', type='char',
string='Party Language', on_change_with=['party'])
invoice_address = fields.Many2One('party.address', 'Invoice Address',
required=True, states=_STATES, domain=["('party', '=', party)"])
required=True, states=_STATES, domain=[('party', '=', Eval('party'))])
currency = fields.Many2One('currency.currency', 'Currency', required=True,
states={
'readonly': "state != 'draft' or (bool(lines) and bool(currency))",
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
And(Bool(Eval('lines')), Bool(Eval('currency')))),
})
currency_digits = fields.Function('get_currency_digits', type='integer',
string='Currency Digits', on_change_with=['currency'])
@@ -76,7 +80,10 @@ class Invoice(ModelWorkflow, ModelSQL, ModelView):
move = fields.Many2One('account.move', 'Move', readonly=True)
account = fields.Many2One('account.account', 'Account', required=True,
states=_STATES,
domain=["('company', '=', company)", ('kind', '!=', 'view')])
domain=[
('company', '=', Eval('company')),
('kind', '!=', 'view'),
])
payment_term = fields.Many2One('account.invoice.payment_term',
'Payment Term', required=True, states=_STATES)
lines = fields.One2Many('account.invoice.line', 'invoice', 'Lines',
@@ -85,13 +92,13 @@ class Invoice(ModelWorkflow, ModelSQL, ModelView):
states=_STATES, on_change=['lines', 'taxes', 'currency', 'party', 'type'])
comment = fields.Text('Comment')
untaxed_amount = fields.Function('get_untaxed_amount', type='numeric',
digits="(16, currency_digits)", string='Untaxed',
digits=(16, Eval('currency_digits', 2)), string='Untaxed',
fnct_search='search_untaxed_amount')
tax_amount = fields.Function('get_tax_amount', type='numeric',
digits="(16, currency_digits)", string='Tax',
digits=(16, Eval('currency_digits', 2)), string='Tax',
fnct_search='search_tax_amount')
total_amount = fields.Function('get_total_amount', type='numeric',
digits="(16, currency_digits)", string='Total',
digits=(16, Eval('currency_digits', 2)), string='Total',
fnct_search='search_total_amount')
reconciled = fields.Function('get_reconciled', type='boolean',
string='Reconciled')
@@ -100,10 +107,10 @@ class Invoice(ModelWorkflow, ModelSQL, ModelView):
payment_lines = fields.Many2Many('account.invoice-account.move.line',
'invoice', 'line', readonly=True, string='Payment Lines')
amount_to_pay_today = fields.Function('get_amount_to_pay',
type='numeric', digits="(16, currency_digits)",
type='numeric', digits=(16, Eval('currency_digits', 2)),
string='Amount to Pay Today')
amount_to_pay = fields.Function('get_amount_to_pay',
type='numeric', digits="(16, currency_digits)",
type='numeric', digits=(16, Eval('currency_digits', 2)),
string='Amount to Pay')
invoice_report = fields.Binary('Invoice Report', readonly=True)
invoice_report_format = fields.Char('Invoice Report Format', readonly=True)
@@ -1267,86 +1274,96 @@ class InvoiceLine(ModelSQL, ModelView):
invoice = fields.Many2One('account.invoice', 'Invoice', ondelete='CASCADE',
select=1, states={
'required': "not bool(globals().get('invoice_type')) " \
"and bool(globals().get('party')) " \
"and bool(globals().get('currency')) " \
"and bool(globals().get('company'))",
'invisible': "context.get('standalone', False)",
})
invoice_type = fields.Selection(_TYPE, 'Invoice Type', select=1, states={
'readonly': "context.get('type', False) or bool(type)",
'required': "not bool(invoice)",
})
party = fields.Many2One('party.party', 'Party', select=1, states={
'required': "not bool(invoice)",
})
'required': And(Not(Bool(Eval('invoice_type'))),
Bool(Eval('party')),
Bool(Eval('currency')),
Bool(Eval('company'))),
'invisible': Bool(Get(Eval('context', {}), 'standalone')),
})
invoice_type = fields.Selection(_TYPE, 'Invoice Type', select=1,
states={
'readonly': Or(Bool(Get(Eval('context', {}), 'type')),
Bool(Eval('type'))),
'required': Not(Bool(Eval('invoice'))),
})
party = fields.Many2One('party.party', 'Party', select=1,
states={
'required': Not(Bool(Eval('invoice'))),
})
party_lang = fields.Function('get_party_language', type='char',
string='Party Language', on_change_with=['party'])
currency = fields.Many2One('currency.currency', 'Currency', states={
'required': "not bool(invoice)",
})
currency = fields.Many2One('currency.currency', 'Currency',
states={
'required': Not(Bool(Eval('invoice'))),
})
currency_digits = fields.Function('get_currency_digits', type='integer',
string='Currency Digits', on_change_with=['currency'])
company = fields.Many2One('company.company', 'Company', states={
'required': "not bool(invoice)",
}, domain=["('id', 'company' in context and '=' or '!=', " \
"context.get('company', 0))"])
company = fields.Many2One('company.company', 'Company',
states={
'required': Not(Bool(Eval('invoice'))),
}, domain=[
('id', If(In('company', Eval('context', {})), '=', '!='),
Get(Eval('context', {}), 'company', 0)),
])
sequence = fields.Integer('Sequence', states={
'invisible': "context.get('standalone', False)",
})
sequence = fields.Integer('Sequence',
states={
'invisible': Bool(Get(Eval('context', {}), 'standalone')),
})
type = fields.Selection([
('line', 'Line'),
('subtotal', 'Subtotal'),
('title', 'Title'),
('comment', 'Comment'),
], 'Type', select=1, required=True, states={
'invisible': "context.get('standalone', False)",
'invisible': Bool(Get(Eval('context', {}), 'standalone')),
})
quantity = fields.Float('Quantity',
digits="(16, unit_digits)",
digits=(16, Eval('unit_digits', 2)),
states={
'invisible': "type != 'line'",
'required': "type == 'line'",
'invisible': Not(Equal(Eval('type'), 'line')),
'required': Equal(Eval('type'), 'line'),
})
unit = fields.Many2One('product.uom', 'Unit',
states={
'required': "product",
'invisible': "type != 'line'",
}, domain=["('category', '=', " \
"(product, 'product.default_uom.category'))"],
context="{'category': (product, 'product.default_uom.category')}")
'required': Bool(Eval('product')),
'invisible': Not(Equal(Eval('type'), 'line')),
}, domain=[
('category', '=',
(Eval('product'), 'product.default_uom.category')),
],
context={
'category': (Eval('product'), 'product.default_uom.category'),
})
unit_digits = fields.Function('get_unit_digits', type='integer',
string='Unit Digits', on_change_with=['unit'])
product = fields.Many2One('product.product', 'Product',
states={
'invisible': "type != 'line'",
'invisible': Not(Equal(Eval('type'), 'line')),
}, on_change=['product', 'unit', 'quantity', 'description',
'_parent_invoice.type', '_parent_invoice.party',
'_parent_invoice.currency', 'party', 'currency'])
account = fields.Many2One('account.account', 'Account',
domain=[('kind', '!=', 'view'),
"('company', '=', " \
"globals().get('_parent_invoice') and " \
"globals().get('_parent_invoice').company or " \
"globals()['company'])",
"('id', '!=', globals().get('_parent_invoice') and " \
"globals().get('_parent_invoice').account or 0)"],
domain=[
('kind', '!=', 'view'),
('company', '=', Get(Eval('_parent_invoice', {}), 'company',
Eval('company'))),
('id', '!=', Get(Eval('_parent_invoice', {}), 'account', 0)),
],
states={
'invisible': "type != 'line'",
'required': "type == 'line'",
'invisible': Not(Equal(Eval('type'), 'line')),
'required': Equal(Eval('type'), 'line'),
})
unit_price = fields.Numeric('Unit Price', digits=(16, 4),
states={
'invisible': "type != 'line'",
'required': "type == 'line'",
'invisible': Not(Equal(Eval('type'), 'line')),
'required': Equal(Eval('type'), 'line'),
})
amount = fields.Function('get_amount', type='numeric', string='Amount',
digits="(16, globals().get('_parent_invoice') and " \
"globals().get('_parent_invoice').currency_digits or " \
"globals()['currency_digits'])",
digits=(16, Get(Eval('_parent_invoice', {}), 'currency_digits',
Eval('currency_digits', 2))),
states={
'invisible': "type not in ('line', 'subtotal')",
'invisible': Not(In(Eval('type'), ['line', 'subtotal'])),
}, on_change_with=['type', 'quantity', 'unit_price',
'_parent_invoice.currency', 'currency'])
description = fields.Text('Description', size=None, required=True)
@@ -1354,7 +1371,7 @@ class InvoiceLine(ModelSQL, ModelView):
taxes = fields.Many2Many('account.invoice.line-account.tax',
'line', 'tax', 'Taxes', domain=[('parent', '=', False)],
states={
'invisible': "type != 'line'",
'invisible': Not(Equal(Eval('type'), 'line')),
})
invoice_taxes = fields.Function('get_invoice_taxes', type='many2many',
relation='account.invoice.tax', string='Invoice Taxes')
@@ -1876,16 +1893,24 @@ class InvoiceTax(ModelSQL, ModelView):
sequence_number = fields.Function('get_sequence_number', type='integer',
string='Sequence Number')
account = fields.Many2One('account.account', 'Account', required=True,
domain=[('kind', '!=', 'view'),
"('company', '=', _parent_invoice.company)"])
base = fields.Numeric('Base', digits="(16, _parent_invoice.currency_digits)")
amount = fields.Numeric('Amount', digits="(16, _parent_invoice.currency_digits)")
domain=[
('kind', '!=', 'view'),
('company', '=', Get(Eval('_parent_invoice', {}), 'company')),
])
base = fields.Numeric('Base',
digits=(16, Get(Eval('_parent_invoice', {}), 'currency_digits', 2)))
amount = fields.Numeric('Amount',
digits=(16, Get(Eval('_parent_invoice', {}), 'currency_digits', 2)))
manual = fields.Boolean('Manual')
base_code = fields.Many2One('account.tax.code', 'Base Code',
domain=["('company', '=', _parent_invoice.company)"])
domain=[
('company', '=', Get(Eval('_parent_invoice', {}), 'company')),
])
base_sign = fields.Numeric('Base Sign', digits=(2, 0))
tax_code = fields.Many2One('account.tax.code', 'Tax Code',
domain=["('company', '=', _parent_invoice.company)"])
domain=[
('company', '=', Get(Eval('_parent_invoice', {}), 'company')),
])
tax_sign = fields.Numeric('Tax Sign', digits=(2, 0))
tax = fields.Many2One('account.tax', 'Tax')
@@ -2173,7 +2198,7 @@ class PayInvoiceInit(ModelView):
'Pay Invoice Init'
_name = 'account.invoice.pay_invoice.init'
_description = __doc__
amount = fields.Numeric('Amount', digits="(16, currency_digits)")
amount = fields.Numeric('Amount', digits=(16, Eval('currency_digits', 2)))
currency = fields.Many2One('currency.currency', 'Currency', required=True)
currency_digits = fields.Integer('Currency Digits', readonly=True,
on_change_with=['currency'])
@@ -2208,45 +2233,51 @@ class PayInvoiceAsk(ModelView):
], 'Type', required=True)
journal_writeoff = fields.Many2One('account.journal', 'Write-Off Journal',
states={
'invisible': "type != 'writeoff'",
'required': "type == 'writeoff'",
'invisible': Not(Equal(Eval('type'), 'writeoff')),
'required': Equal(Eval('type'), 'writeoff'),
})
account_writeoff = fields.Many2One('account.account', 'Write-Off Account',
domain=[('kind', '!=', 'view'), "('company', '=', company)"],
domain=[
('kind', '!=', 'view'),
('company', '=', Eval('company')),
],
states={
'invisible': "type != 'writeoff'",
'required': "type == 'writeoff'",
'invisible': Not(Equal(Eval('type'), 'writeoff')),
'required': Equal(Eval('type'), 'writeoff'),
})
amount = fields.Numeric('Payment Amount', digits="(16, currency_digits)",
amount = fields.Numeric('Payment Amount',
digits=(16, Eval('currency_digits', 2)),
readonly=True, depends=['currency_digits'])
currency = fields.Many2One('currency.currency', 'Payment Currency',
readonly=True)
currency_digits = fields.Integer('Payment Currency Digits', readonly=True)
amount_writeoff = fields.Numeric('Write-Off Amount',
digits="(16, currency_digits_writeoff)", readonly=True,
digits=(16, Eval('currency_digits_writeoff', 2)), readonly=True,
depends=['currency_digits_writeoff'], states={
'invisible': "type != 'writeoff'",
'invisible': Not(Equal(Eval('type'), 'writeoff')),
})
currency_writeoff = fields.Many2One('currency.currency',
'Write-Off Currency', readonly=True, states={
'invisible': "type != 'writeoff'",
'invisible': Not(Equal(Eval('type'), 'writeoff')),
})
currency_digits_writeoff = fields.Integer('Write-Off Currency Digits',
readonly=True)
lines_to_pay = fields.Many2Many('account.move.line', None, None,
'Lines to Pay', readonly=True)
lines = fields.Many2Many('account.move.line', None, None, 'Lines',
domain=["('id', 'in', lines_to_pay)",
('reconciliation', '=', False)],
domain=[
('id', 'in', Eval('lines_to_pay')),
('reconciliation', '=', False),
],
states={
'invisible': "type != 'writeoff'",
'invisible': Not(Equal(Eval('type'), 'writeoff')),
}, on_change=['lines', 'amount', 'currency', 'currency_writeoff',
'invoice'],
depends=['lines_to_pay'])
payment_lines = fields.Many2Many('account.move.line', None, None,
'Payment Lines', readonly=True,
states={
'invisible': "type != 'writeoff'",
'invisible': Not(Equal(Eval('type'), 'writeoff')),
})
description = fields.Char('Description', size=None, readonly=True)
journal = fields.Many2One('account.journal', 'Journal', readonly=True,
+10 -9
View File
@@ -91,24 +91,24 @@ this repository contains the full copyright notices and license terms. -->
</group>
<group col="5" colspan="2" id="buttons">
<button name="cancel" string="_Cancel"
states="{'invisible': '''state not in ('draft', 'proforma')''', 'readonly': '''%(account.group_account)d not in groups'''}"
states="{'invisible': Not(In(Eval('state'), ['draft', 'proforma'])), 'readonly': Not(In(%(account.group_account)d, Eval('groups', [])))}"
icon="tryton-cancel"/>
<button name="button_draft" string="_Reset to Draft"
type="object"
states="{'invisible': '''state != 'cancel' '''}"
states="{'invisible': Not(Equal(Eval('state'), 'cancel'))}"
icon="tryton-clear"/>
<button name="draft" string="_Draft"
states="{'invisible': '''state != 'proforma' '''}"
states="{'invisible': Not(Equal(Eval('state'), 'proforma'))}"
icon="tryton-go-previous"/>
<button name="proforma" string="Pro For_ma"
states="{'invisible': '''state != 'draft' '''}"
states="{'invisible': Not(Equal(Eval('state'), 'draft'))}"
icon="tryton-go-next"/>
<button name="open" string="_Open"
states="{'invisible': '''state not in ('draft', 'proforma')''', 'readonly': '''%(account.group_account)d not in groups'''}"
states="{'invisible': Not(In(Eval('state'), ['draft', 'proforma'])), 'readonly': Not(In(%(account.group_account)d, Eval('groups', [])))}"
icon="tryton-ok"/>
<button name="%(wizard_pay_invoice)d" string="_Pay"
type="action"
states="{'invisible': '''state != 'open' ''', 'readonly': '''%(account.group_account)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'open')), 'readonly': Not(In(%(account.group_account)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
</group>
</group>
@@ -124,7 +124,8 @@ this repository contains the full copyright notices and license terms. -->
<label name="move"/>
<field name="move"/>
<separator name="comment" colspan="4"/>
<field name="comment" colspan="4" spell="party_lang"/>
<field name="comment" colspan="4"
spell="Eval('party_lang')"/>
</page>
<page string="Payment" id="payment">
<label name="amount_to_pay_today"/>
@@ -735,7 +736,7 @@ this repository contains the full copyright notices and license terms. -->
<newline/>
<label name="description"/>
<field name="description" colspan="3"
spell="globals().get('_parent_invoice') and _parent_invoice.party_lang or party_lang"/>
spell="If(Bool(Eval('_parent_invoice')), Get(Eval('_parent_invoice', {}), 'party_lang'), Eval('party_lang'))"/>
<label name="quantity"/>
<field name="quantity"/>
<label name="unit"/>
@@ -750,7 +751,7 @@ this repository contains the full copyright notices and license terms. -->
<page string="Notes" id="notes">
<separator name="note" colspan="4"/>
<field name="note" colspan="4"
spell="globals().get('_parent_invoice') and _parent_invoice.party_lang or party_lang"/>
spell="If(Bool(Eval('_parent_invoice')), Get(Eval('_parent_invoice', {}), 'party_lang'), Eval('party_lang'))"/>
</page>
</notebook>
<field name="unit_digits" invisible="1" colspan="4"/>
+1 -1
View File
@@ -58,7 +58,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="domain">[("party", "=", active_id)]</field>
<field name="domain">[("party", "=", Eval('active_id'))]</field>
</record>
<record model="ir.action.keyword"
id="act_open_invoice_keyword1">
+8 -7
View File
@@ -2,6 +2,7 @@
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.backend import TableHandler
from trytond.pyson import Not, Equal, Eval
from decimal import Decimal
import datetime
import time
@@ -132,18 +133,18 @@ class PaymentTermLine(ModelSQL, ModelView):
on_change=['type'])
percentage = fields.Numeric('Percentage', digits=(16, 8),
states={
'invisible': "type != 'percent'",
'required': "type == 'percent'",
'invisible': Not(Equal(Eval('type'), 'percent')),
'required': Equal(Eval('type'), 'percent'),
}, help='In %')
amount = fields.Numeric('Amount', digits="(16, currency_digits)",
amount = fields.Numeric('Amount', digits=(16, Eval('currency_digits', 2)),
states={
'invisible': "type != 'fixed'",
'required': "type == 'fixed'",
'invisible': Not(Equal(Eval('type'), 'fixed')),
'required': Equal(Eval('type'), 'fixed'),
})
currency = fields.Many2One('currency.currency', 'Currency',
states={
'invisible': "type != 'fixed'",
'required': "type == 'fixed'",
'invisible': Not(Equal(Eval('type'), 'fixed')),
'required': Equal(Eval('type'), 'fixed'),
})
currency_digits = fields.Function('get_currency_digits', type='integer',
string='Currency Digits', on_change_with=['currency'])