diff --git a/modules/timesheet/ir.py b/modules/timesheet/ir.py index 465430b4e8..1a96e56171 100644 --- a/modules/timesheet/ir.py +++ b/modules/timesheet/ir.py @@ -3,6 +3,13 @@ from trytond.pool import Pool, PoolMeta +_EMPLOYEES_RULE_MODELS = { + 'timesheet.line', + 'timesheet.hours_employee', + 'timesheet.hours_employee_weekly', + 'timesheet.hours_employee_monthly', + } + class Rule(metaclass=PoolMeta): __name__ = 'ir.rule' @@ -12,7 +19,7 @@ class Rule(metaclass=PoolMeta): pool = Pool() User = pool.get('res.user') context = super()._get_context(model_name) - if model_name == 'timesheet.line': + if model_name in _EMPLOYEES_RULE_MODELS: context['employees'] = User.get_employees() return context @@ -21,6 +28,6 @@ class Rule(metaclass=PoolMeta): pool = Pool() User = pool.get('res.user') key = super()._get_cache_key(model_name) - if model_name == 'timesheet.line': + if model_name in _EMPLOYEES_RULE_MODELS: key = (*key, User.get_employees()) return key