From 858758af472bc493ee6cc10dcb02ddadb57dec7b Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Thu, 2 Feb 2012 14:22:55 +0530 Subject: [PATCH 1/3] [FIX] account : COA Creation wizard hangs up lp bug: https://launchpad.net/bugs/923884 fixed bzr revid: mdi@tinyerp.com-20120202085255-jpuv9x6i33nnjp8f --- addons/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index b97fd870749..3f92aef60b2 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3358,7 +3358,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): # and the next number for account code might have been already used before for journal journal_count = 0 while True: - journal_code = _('BNK') + str(current_num + journal_count) + 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 From f0dbcdcfe724fcdd73e84b4f4915471c16a64f0a Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Fri, 3 Feb 2012 11:35:47 +0530 Subject: [PATCH 2/3] [IMP] account : Improved the code. bzr revid: mdi@tinyerp.com-20120203060547-opr31t6snhhxk47c --- addons/account/account.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 3f92aef60b2..8ed4335e67e 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -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'], From bf7c5f68f0b34a1a6f6b0adc5efd535b5aa96f79 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Fri, 3 Feb 2012 11:53:23 +0530 Subject: [PATCH 3/3] [IMP] account : Improved the code. bzr revid: mdi@tinyerp.com-20120203062323-7snclf0vtc73dsai --- addons/account/account.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 8ed4335e67e..785c2f680c4 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3356,14 +3356,12 @@ class wizard_multi_charts_accounts(osv.osv_memory): # because we can't rely on the value current_num as, # 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 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) + journal_code = _('BNK')[:3] + str(num) 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.'))