BASE: prevent recursion in company
bzr revid: ced-f1755f17b6856c1f422b8b96e60234fa437cf926
This commit is contained in:
parent
fdb6e3c889
commit
450e8964ba
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue