diff --git a/.gitignore b/.hgignore similarity index 88% rename from .gitignore rename to .hgignore index f5d0da5..bb7a7a5 100644 --- a/.gitignore +++ b/.hgignore @@ -1,4 +1,4 @@ -*.pyc +syntax: glob build/* dist/* mds_cashbook.egg-info/* diff --git a/ir.py b/ir.py index 0f81aec..4054d93 100644 --- a/ir.py +++ b/ir.py @@ -3,6 +3,7 @@ # The COPYRIGHT file at the top level of this repository contains the # full copyright notices and license terms. +from trytond.transaction import Transaction from trytond.pool import PoolMeta @@ -13,12 +14,22 @@ class Rule(metaclass=PoolMeta): def _context_modelnames(cls): """ list of models to add 'user_id' to context """ - result = super(Rule, cls)._context_modelnames() - return result | { - 'cashbook.book', - 'cashbook.line', - 'cashbook.recon', - 'cashbook.split' - } + return [ + 'cashbook.book', 'cashbook.line', 'cashbook.recon', + 'cashbook.split'] + + @classmethod + def _get_context(cls, model_name): + context = super()._get_context(model_name) + 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 cls._context_modelnames(): + key = (*key, Transaction().user) + return key # end Rule diff --git a/tryton.cfg b/tryton.cfg index be3f103..9867dfe 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -5,7 +5,6 @@ depends: currency party company - irrulecontext xml: icon.xml group.xml diff --git a/versiondep.txt b/versiondep.txt index d501ebb..8b13789 100644 --- a/versiondep.txt +++ b/versiondep.txt @@ -1 +1 @@ -irrulecontext;7.0.1;7.0.999;mds +