From 7fc8a83b4b56df4ead683576d1675fec354086a4 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 10 Jun 2013 13:04:01 +0200 Subject: [PATCH] [FIX] account: restrict bank account post creation for account and journal Do not create account and journal when there no liquidity account with a parent. This removes a traceback but may lead to no auto configuration. This is not considered as critical as we prefer that instead of configuring wrongly accounts and journals bzr revid: mat@openerp.com-20130610110401-1pgpql7r688et8sp --- addons/account/account_bank.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/account/account_bank.py b/addons/account/account_bank.py index 44411cd637a..acb0e640a7a 100644 --- a/addons/account/account_bank.py +++ b/addons/account/account_bank.py @@ -65,12 +65,11 @@ class bank(osv.osv): # Find the code and parent of the bank account to create dig = 6 current_num = 1 - ids = obj_acc.search(cr, uid, [('type','=','liquidity'), ('company_id', '=', bank.company_id.id)], context=context) + ids = obj_acc.search(cr, uid, [('type','=','liquidity'), ('company_id', '=', bank.company_id.id), ('parent_id', '!=', False)], context=context) # No liquidity account exists, no template available if not ids: continue - ref_acc_bank_temp = obj_acc.browse(cr, uid, ids[0], context=context) - ref_acc_bank = ref_acc_bank_temp.parent_id + ref_acc_bank = obj_acc.browse(cr, uid, ids[0], context=context).parent_id while True: new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)), '0')) + str(current_num) ids = obj_acc.search(cr, uid, [('code', '=', new_code), ('company_id', '=', bank.company_id.id)]) @@ -82,7 +81,7 @@ class bank(osv.osv): 'name': name, 'code': new_code, 'type': 'liquidity', - 'user_type': ref_acc_bank_temp.user_type.id, + 'user_type': ref_acc_bank.user_type.id, 'reconcile': False, 'parent_id': ref_acc_bank.id, 'company_id': bank.company_id.id,