2023-11-30 12:18:14 +00:00
|
|
|
# -*- 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'
|
|
|
|
|
2023-12-04 19:06:02 +00:00
|
|
|
@classmethod
|
|
|
|
def _context_modelnames(cls):
|
|
|
|
""" list of models to add 'user_id' to context
|
|
|
|
"""
|
2023-12-13 20:52:27 +00:00
|
|
|
return [
|
|
|
|
'cashbook.book', 'cashbook.line', 'cashbook.recon',
|
|
|
|
'cashbook.split']
|
2023-12-04 19:06:02 +00:00
|
|
|
|
2023-11-30 12:18:14 +00:00
|
|
|
@classmethod
|
|
|
|
def _get_context(cls, model_name):
|
|
|
|
context = super()._get_context(model_name)
|
2023-12-04 19:06:02 +00:00
|
|
|
if model_name in cls._context_modelnames():
|
2023-11-30 12:18:14 +00:00
|
|
|
context['user_id'] = Transaction().user
|
|
|
|
return context
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _get_cache_key(cls, model_name):
|
|
|
|
key = super()._get_cache_key(model_name)
|
2023-12-04 19:06:02 +00:00
|
|
|
if model_name in cls._context_modelnames():
|
2023-11-30 12:18:14 +00:00
|
|
|
key = (*key, Transaction().user)
|
|
|
|
return key
|
|
|
|
|
|
|
|
# end Rule
|