Add employees to rule context for timesheet reporting models
Closes #13038
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user