Tryton 7.0: ir.rule: Eval('user', ...) --> Eval('user_id', -1)

This commit is contained in:
Frederik Jaeckel 2023-11-30 13:18:14 +01:00
parent fbdc68c642
commit 7062399319
6 changed files with 33 additions and 4 deletions

View file

@ -17,6 +17,7 @@ from .reconciliation import Reconciliation
from .cbreport import ReconciliationReport from .cbreport import ReconciliationReport
from .currency import CurrencyRate from .currency import CurrencyRate
from .model import MemCache from .model import MemCache
from .ir import Rule
def register(): def register():
@ -35,6 +36,7 @@ def register():
OpenCashBookStart, OpenCashBookStart,
RunCbReportStart, RunCbReportStart,
EnterBookingStart, EnterBookingStart,
Rule,
module='cashbook', type_='model') module='cashbook', type_='model')
Pool.register( Pool.register(
ReconciliationReport, ReconciliationReport,

View file

@ -121,7 +121,7 @@ full copyright notices and license terms. -->
</record> </record>
<record model="ir.rule" id="rg_book_rw_owner-1"> <record model="ir.rule" id="rg_book_rw_owner-1">
<field name="domain" eval="[ <field name="domain" eval="[
('owner.id', '=', Eval('user', {}).get('id', -1)), ('owner.id', '=', Eval('user_id', -1)),
]" pyson="1"/> ]" pyson="1"/>
<field name="rule_group" ref="rg_book_rw_owner"/> <field name="rule_group" ref="rg_book_rw_owner"/>
</record> </record>

27
ir.py Normal file
View file

@ -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

View file

@ -145,7 +145,7 @@ full copyright notices and license terms. -->
</record> </record>
<record model="ir.rule" id="rg_line_write-1"> <record model="ir.rule" id="rg_line_write-1">
<field name="domain" eval="['OR', <field name="domain" eval="['OR',
('cashbook.owner.id', '=', Eval('user', {}).get('id', -1)), ('cashbook.owner.id', '=', Eval('user_id', -1)),
('cashbook.reviewer.id', 'in', Eval('groups', [])), ('cashbook.reviewer.id', 'in', Eval('groups', [])),
]" pyson="1"/> ]" pyson="1"/>
<field name="rule_group" ref="rg_line_write"/> <field name="rule_group" ref="rg_line_write"/>

View file

@ -96,7 +96,7 @@ full copyright notices and license terms. -->
</record> </record>
<record model="ir.rule" id="rg_recon_write-1"> <record model="ir.rule" id="rg_recon_write-1">
<field name="domain" eval="['OR', <field name="domain" eval="['OR',
('cashbook.owner.id', '=', Eval('user', {}).get('id', -1)), ('cashbook.owner.id', '=', Eval('user_id', -1)),
('cashbook.reviewer.id', 'in', Eval('groups', [])), ('cashbook.reviewer.id', 'in', Eval('groups', [])),
]" pyson="1"/> ]" pyson="1"/>
<field name="rule_group" ref="rg_recon_write"/> <field name="rule_group" ref="rg_recon_write"/>

View file

@ -80,7 +80,7 @@ full copyright notices and license terms. -->
</record> </record>
<record model="ir.rule" id="rg_split_write-1"> <record model="ir.rule" id="rg_split_write-1">
<field name="domain" eval="['OR', <field name="domain" eval="['OR',
('line.cashbook.owner.id', '=', Eval('user', {}).get('id', -1)), ('line.cashbook.owner.id', '=', Eval('user_id', -1)),
('line.cashbook.reviewer.id', 'in', Eval('groups', [])), ('line.cashbook.reviewer.id', 'in', Eval('groups', [])),
]" pyson="1"/> ]" pyson="1"/>
<field name="rule_group" ref="rg_split_write"/> <field name="rule_group" ref="rg_split_write"/>