account, kernel: fix recursion in analytic account

- add constraint against recursion (in orm)
- modify compute quantity, because now browse record in recursive compute will no more work.

bzr revid: ced-4f2a6158659ee9b00e45069429868af1f32f3a24
This commit is contained in:
ced 2007-07-30 13:35:15 +00:00
parent c63d065d75
commit 0c7faf0ea1
1 changed files with 13 additions and 0 deletions

View File

@ -1781,4 +1781,17 @@ class orm(object):
self.pool.get(table).write_string(cr, uid, id, langs, vals, context)
return True
def check_recursion(self, cr, uid, ids, parent=None):
if not parent:
parent = self._parent_name
ids_parent = ids[:]
while len(ids_parent):
cr.execute('SELECT distinct '+self._parent_name+
' FROM '+self._table+' WHERE id in ('+','.join(map(str, ids_parent))+')')
ids_parent = filter(None, map(lambda x: x[0], cr.fetchall()))
for i in ids_parent:
if i in ids:
return False
return True
# vim:noexpandtab:ts=4