Add required on move lines for account of kind 'receivable', 'payable'

This commit is contained in:
Cédric Krier committed 2008-09-23 19:06:56 +02:00
1 parent 896a0eb772
commit 87705ea49c
2 files changed
+25 -2

No files matched your search

+23 -2
View File
@@ -377,7 +377,9 @@ class Line(OSV):
help='The second currency')
party = fields.Many2One('relationship.party', 'Party',
on_change=['move', 'party', 'account', 'debit', 'credit',
'journal'], select=1)
'journal'], select=1, states={
'required': "account_kind in ('payable', 'receivable')",
})
blocked = fields.Boolean('Litigation',
help='Mark the line as litigation with the party.')
maturity_date = fields.Date('Maturity Date',
@@ -400,6 +402,15 @@ class Line(OSV):
string='Currency Digits')
second_currency_digits = fields.Function('get_currency_digits',
type='integer', string='Second Currency Digits')
account_kind = fields.Function('get_account_kind', type='selection',
string='Account Kind', selection=[
('other', 'Other'),
('payable', 'Payable'),
('revenue', 'Revenue'),
('receivable', 'Receivable'),
('expense', 'Expense'),
('view', 'View'),
])
def __init__(self):
super(Line, self).__init__()
@@ -612,6 +623,12 @@ class Line(OSV):
res[name][line.id] = line.account.second_currency.digits
return res
def get_account_kind(self, cursor, user, ids, name, arg, context=None):
res = {}
for line in self.browse(cursor, user, ids, context=context):
res[line.id] = line.account.kind
return res
def on_change_debit(self, cursor, user, ids, vals, context=None):
res = {}
if context is None:
@@ -650,11 +667,12 @@ class Line(OSV):
def on_change_account(self, cursor, user, ids, vals, context=None):
account_obj = self.pool.get('account.account')
journal_obj = self.pool.get('account.journal')
res = {}
if context is None:
context = {}
journal_obj = self.pool.get('account.journal')
if context.get('journal'):
journal = journal_obj.browse(cursor, user,
context['journal'], context=context)
@@ -663,12 +681,15 @@ class Line(OSV):
ids, vals, journal.type, context=context)
if not res['tax_lines']:
del res['tax_lines']
res['account_kind'] = 'other'
if vals.get('account'):
account = account_obj.browse(cursor, user, vals['account'],
context=context)
res['currency_digits'] = account.currency_digits
if account.second_currency:
res['second_currency_digits'] = account.second_currency.digits
res['account_kind'] = account.kind
return res
def _compute_tax_lines(self, cursor, user, ids, vals, journal_type,
+2
View File
@@ -204,6 +204,7 @@
</notebook>
<field name="currency_digits" colspan="4" invisible="1"/>
<field name="second_currency_digits" colspan="4" invisible="1"/>
<field name="account_kind" colspan="4" invisible="1"/>
</form>
]]>
</field>
@@ -228,6 +229,7 @@
<field name="state" select="2"/>
<field name="move_state" select="2"/>
<field name="currency_digits" tree_invisible="1"/>
<field name="account_kind" tree_invisible="1"/>
</tree>
]]>
</field>