diff --git a/move.py b/move.py
index 413262705b..f33010a699 100644
--- a/move.py
+++ b/move.py
@@ -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,
diff --git a/move.xml b/move.xml
index c2442c29e8..de10838949 100644
--- a/move.xml
+++ b/move.xml
@@ -204,6 +204,7 @@
+
]]>
@@ -228,6 +229,7 @@
+
]]>