[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-20130610130047-wlxrrzc7awq80592
This commit is contained in:
commit
ad78ae99b2
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue