[IMP] account : Improved the code.

bzr revid: mdi@tinyerp.com-20120203060547-opr31t6snhhxk47c
This commit is contained in:
Divyesh Makwana (Open ERP) 2012-02-03 11:35:47 +05:30
parent 858758af47
commit f0dbcdcfe7
1 changed files with 4 additions and 1 deletions

View File

@ -3357,12 +3357,15 @@ class wizard_multi_charts_accounts(osv.osv_memory):
# its possible that we already have bank journals created (e.g. by the creation of res.partner.bank)
# and the next number for account code might have been already used before for journal
journal_count = 0
while True:
for num in xrange(current_num, 100):
# journal_code has a maximal size of 5, hence we can enforce the boundary num < 100
journal_code = _('BNK')[:3] + str(current_num + journal_count)
ids = obj_journal.search(cr, uid, [('code', '=', journal_code), ('company_id', '=', company_id)], context=context)
if not ids:
break
journal_count += 1
else:
raise osv.except_osv(_('Error'), _('Cannot generate an unused journal code.'))
vals = {
'name': line['acc_name'],