allow extension of context-models
This commit is contained in:
parent
7e6d2660ad
commit
72f0325a71
1 changed files with 8 additions and 2 deletions
10
ir.py
10
ir.py
|
@ -10,17 +10,23 @@ from trytond.pool import PoolMeta
|
||||||
class Rule(metaclass=PoolMeta):
|
class Rule(metaclass=PoolMeta):
|
||||||
__name__ = 'ir.rule'
|
__name__ = 'ir.rule'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _context_modelnames(cls):
|
||||||
|
""" list of models to add 'user_id' to context
|
||||||
|
"""
|
||||||
|
return ['cashbook.book', 'cashbook.line', 'cashbook.recon']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_context(cls, model_name):
|
def _get_context(cls, model_name):
|
||||||
context = super()._get_context(model_name)
|
context = super()._get_context(model_name)
|
||||||
if model_name in {'cashbook.book', 'cashbook.line', 'cashbook.recon'}:
|
if model_name in cls._context_modelnames():
|
||||||
context['user_id'] = Transaction().user
|
context['user_id'] = Transaction().user
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_cache_key(cls, model_name):
|
def _get_cache_key(cls, model_name):
|
||||||
key = super()._get_cache_key(model_name)
|
key = super()._get_cache_key(model_name)
|
||||||
if model_name in {'cashbook.book', 'cashbook.line', 'cashbook.recon'}:
|
if model_name in cls._context_modelnames():
|
||||||
key = (*key, Transaction().user)
|
key = (*key, Transaction().user)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue