[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
This commit is contained in:
Olivier Dony 2012-02-23 15:16:35 +01:00
parent 12825e4122
commit 819334f0aa
1 changed files with 4 additions and 6 deletions

View File

@ -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)]