From ccf3cd510daae193702a4f4c743e8ff6916a0faf Mon Sep 17 00:00:00 2001 From: "ced@b2ck.com" Date: Thu, 27 Dec 2007 21:13:15 +0100 Subject: [PATCH] Allow child_of query on id --- trytond/osv/orm.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 79f0de947d..74f66ed441 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -1861,6 +1861,16 @@ class ORM(object): fargs = args[i][0].split('.', 1) field = table._columns.get(fargs[0], False) if not field: + if args[i][0] == 'id' and args[i][1] == 'child_of': + ids2 = args[i][2] + def _rec_get(ids, table, parent): + if not ids: + return [] + ids2 = table.search(cursor, user, + [(parent, 'in', ids)], context=context) + return ids2 + _rec_get(ids2, table, parent) + args[i] = (args[i][0], 'in', ids2 + \ + _rec_get(ids2, table, table._parent_name), table) i += 1 continue if len(fargs) > 1: