From 0c7faf0ea113c1d820f17f10325a5907b1ebcc6f Mon Sep 17 00:00:00 2001 From: ced <> Date: Mon, 30 Jul 2007 13:35:15 +0000 Subject: [PATCH] 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 --- bin/osv/orm.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 28022addb94..e8c7326038d 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -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