From 56c08e486f6f349b5dbf701cfd3dcc232903487a Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 10 Nov 2015 16:31:29 +0100 Subject: [PATCH] [FIX] expression: `child_of` domain with `parent_store` & non-existing parent In the `product.template` model, when searching products within a category that doesn't exist, all products were returned, while none should be returned. For instance, In Sales > Products, In the search input, search with internal category: "A category that doesn't exist", all products were returned. opw-649548 --- openerp/osv/expression.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index 417d03c4bb0..ecf01d86618 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -729,6 +729,8 @@ class expression(object): """ Return a domain implementing the child_of operator for [(left,child_of,ids)], either as a range using the parent_left/right tree lookup fields (when available), or as an expanded [(left,in,child_ids)] """ + if not ids: + return FALSE_DOMAIN if left_model._parent_store and (not left_model.pool._init): # TODO: Improve where joins are implemented for many with '.', replace by: # doms += ['&',(prefix+'.parent_left','<',o.parent_right),(prefix+'.parent_left','>=',o.parent_left)]