Add employees to rule context for timesheet reporting models

Closes #13038
This commit is contained in:
Sergi Almacellas Abellana
2024-02-16 00:35:52 +01:00
parent 58fed762e5
commit af093904ef
+9 -2
View File
@@ -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