[FIX] move validation
bzr revid: fp@tinyerp.com-20100901165505-gpalmu0zqhox3eon
This commit is contained in:
parent
d16ca8293d
commit
590184a89c
|
@ -1159,16 +1159,16 @@ class account_move(osv.osv):
|
|||
return chart_account
|
||||
|
||||
for move in self.browse(cursor, user, ids):
|
||||
lines = move.line_id
|
||||
if lines:
|
||||
ref_line = lines[0]
|
||||
ref_chart_account = _get_chart_account(cursor, user, ref_line.account_id)
|
||||
parent_left = ref_chart_account.parent_left
|
||||
parent_right = ref_chart_account.parent_right
|
||||
result = True
|
||||
for line in lines[1:]:
|
||||
if not (line.account_id.parent_left > parent_left and line.account_id.parent_left < parent_right):
|
||||
raise osv.except_osv(_('Error !'), _('You cannot validate a move unless accounts in its entry lines are in same Chart Of Accounts !'))
|
||||
top = None
|
||||
for line in move.line_id:
|
||||
account = line.account_id
|
||||
while account:
|
||||
account2 = account
|
||||
account = account.parent_id
|
||||
if not top:
|
||||
top = account2.id
|
||||
elif top<>account2.id:
|
||||
raise osv.except_osv(_('Error !'), _('You cannot validate a Journal Entry unless all journal items are in same chart of accounts !'))
|
||||
return self.post(cursor, user, ids, context=context)
|
||||
|
||||
def button_cancel(self, cr, uid, ids, context={}):
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
-
|
||||
I check that Initially account move state is "Draft"
|
||||
-
|
||||
!assert {model: account.move, id: account_move_0}:
|
||||
!assert {model: account.move, id: account_move_0, string: initialstatedraft}:
|
||||
- state == 'draft'
|
||||
-
|
||||
I validate this account move by using the 'Validate Journal Entries' wizard
|
||||
|
@ -46,18 +46,12 @@
|
|||
journal_id: account.bank_journal
|
||||
period_id: account.period_6
|
||||
-
|
||||
I clicked on validate Button
|
||||
I click on validate Button
|
||||
-
|
||||
!python {model: validate.account.move}: |
|
||||
try:
|
||||
self.validate_move(cr, uid, [ref("validate_account_move_0")], {"lang": "en_US",
|
||||
"active_model": "ir.ui.menu", "active_ids": [ref("account.menu_validate_account_moves")],
|
||||
"tz": False, "active_id": ref("account.menu_validate_account_moves"), })
|
||||
except:
|
||||
pass
|
||||
|
||||
self.validate_move(cr, uid, [ref("validate_account_move_0")], {"lang": "en_US", "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_validate_account_moves")], "tz": False, "active_id": ref("account.menu_validate_account_moves"), })
|
||||
-
|
||||
I check that the invoice state is now "Posted"
|
||||
-
|
||||
!assert {model: account.move, id: account_move_0}:
|
||||
!assert {model: account.move, id: account_move_0, string: moveincorrect}:
|
||||
- state == 'posted'
|
||||
|
|
Loading…
Reference in New Issue