From a2ce7ee704454493017437e1dc250f0fd71da0b0 Mon Sep 17 00:00:00 2001 From: ced <> Date: Wed, 27 Jun 2007 06:18:48 +0000 Subject: [PATCH] ACCOUNT: add check recursion in account.tax.code bzr revid: ced-188ddf0d68f8f791fc81a473e8d2545972ced237 --- addons/account/account.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index b286e890744..00f4f8cf957 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -850,19 +850,19 @@ class account_tax_code(osv.osv): _defaults = { 'company_id': _default_company, } - #def _check_recursion(self, cr, uid, ids): - # level = 100 - # while len(ids): - # cr.execute('select distinct parent_id from account_account_rel where child_id in ('+','.join(map(str,ids))+')') - # ids = filter(None, map(lambda x:x[0], cr.fetchall())) - # if not level: - # return False - # level -= 1 - # return True + def _check_recursion(self, cr, uid, ids): + level = 100 + while len(ids): + cr.execute('select distinct parent_id from account_tax_code where id in ('+','.join(map(str,ids))+')') + ids = filter(None, map(lambda x:x[0], cr.fetchall())) + if not level: + return False + level -= 1 + return True - #_constraints = [ - # (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) - #] + _constraints = [ + (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) + ] _order = 'name' account_tax_code()