diff --git a/__init__.py b/__init__.py index 5439e0e..80f7161 100644 --- a/__init__.py +++ b/__init__.py @@ -17,6 +17,7 @@ from .reconciliation import Reconciliation from .cbreport import ReconciliationReport from .currency import CurrencyRate from .model import MemCache +from .ir import Rule def register(): @@ -35,6 +36,7 @@ def register(): OpenCashBookStart, RunCbReportStart, EnterBookingStart, + Rule, module='cashbook', type_='model') Pool.register( ReconciliationReport, diff --git a/book.xml b/book.xml index 4520409..b455f14 100644 --- a/book.xml +++ b/book.xml @@ -121,7 +121,7 @@ full copyright notices and license terms. --> diff --git a/ir.py b/ir.py new file mode 100644 index 0000000..7aa9aca --- /dev/null +++ b/ir.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# This file is part of the cashbook-module from m-ds.de for Tryton. +# 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 + + +class Rule(metaclass=PoolMeta): + __name__ = 'ir.rule' + + @classmethod + def _get_context(cls, model_name): + context = super()._get_context(model_name) + if model_name in {'cashbook.book', 'cashbook.line', 'cashbook.recon'}: + 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'}: + key = (*key, Transaction().user) + return key + +# end Rule diff --git a/line.xml b/line.xml index e618696..624fbfd 100644 --- a/line.xml +++ b/line.xml @@ -145,7 +145,7 @@ full copyright notices and license terms. --> diff --git a/reconciliation.xml b/reconciliation.xml index ca2f603..530a1ca 100644 --- a/reconciliation.xml +++ b/reconciliation.xml @@ -96,7 +96,7 @@ full copyright notices and license terms. --> diff --git a/splitline.xml b/splitline.xml index 4ab74c0..fefec00 100644 --- a/splitline.xml +++ b/splitline.xml @@ -80,7 +80,7 @@ full copyright notices and license terms. -->