From 819334f0aa97ca37a7b3b40c9da9c3b8f4798fe7 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 23 Feb 2012 15:16:35 +0100 Subject: [PATCH] [FIX] orm: inherited `active` fields should be used for the implicit filtering This is for example used by hr.employee which inherits from resource.resource, with the `active` field located on the resource model. Simplified some code too. bzr revid: odo@openerp.com-20120223141635-p117b5wvvreuj40c --- openerp/osv/orm.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index d86c15e43a3..c1822b4fe0a 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -4382,13 +4382,11 @@ class BaseModel(object): domain = domain[:] # if the object has a field named 'active', filter out all inactive # records unless they were explicitely asked for - if 'active' in self._columns and (active_test and context.get('active_test', True)): + if 'active' in self._all_columns and (active_test and context.get('active_test', True)): if domain: - active_in_args = False - for a in domain: - if a[0] == 'active': - active_in_args = True - if not active_in_args: + # the item[0] trick below works for domain items and '&'/'|'/'!' + # operators too + if not any(item[0] == 'active' for item in domain): domain.insert(0, ('active', '=', 1)) else: domain = [('active', '=', 1)]