BASE: prevent recursion in company

bzr revid: ced-f1755f17b6856c1f422b8b96e60234fa437cf926
This commit is contained in:
ced 2007-02-22 07:35:38 +00:00
parent fdb6e3c889
commit 450e8964ba
1 changed files with 14 additions and 0 deletions

View File

@ -97,9 +97,23 @@ class res_company(osv.osv):
except:
return 1
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
cr.execute('select distinct parent_id from res_company 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
_defaults = {
'currency_id': _get_euro,
}
_constraints = [
(_check_recursion, 'Error! You can not create recursive companies.', ['parent_id'])
]
res_company()