-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathir.py
26 lines (22 loc) · 831 Bytes
/
ir.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
class Rule(metaclass=PoolMeta):
__name__ = 'ir.rule'
@classmethod
def _get_context(cls, model_name):
pool = Pool()
User = pool.get('res.user')
context = super()._get_context(model_name)
if model_name == 'babi.warning':
context['employees'] = User.get_employees()
if model_name in ('babi.warning', 'babi.table'):
context['user_id'] = Transaction().user
return context
@classmethod
def _get_cache_key(cls, model_name):
pool = Pool()
User = pool.get('res.user')
key = super()._get_cache_key(model_name)
if model_name == 'babi.warning':
key = (*key, User.get_employees(), Transaction().user)
return key