From 72f0325a71f8a5a9e59051a7d104dd5ba6e50c53 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Mon, 4 Dec 2023 20:06:02 +0100 Subject: [PATCH] allow extension of context-models --- ir.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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