diff --git a/ir.py b/ir.py index 7aa9aca..1456371 100644 --- a/ir.py +++ b/ir.py @@ -10,17 +10,23 @@ from trytond.pool import PoolMeta class Rule(metaclass=PoolMeta): __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 def _get_context(cls, 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 return context @classmethod def _get_cache_key(cls, 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) return key