ir-rule: condition --> Eval('user_id', -1)

This commit is contained in:
Frederik Jaeckel 2023-12-04 20:05:06 +01:00
parent 6b94179b42
commit 0f11e9d5a1
3 changed files with 23 additions and 1 deletions

View file

@ -6,6 +6,7 @@
from trytond.pool import Pool
from .category import Category
from .book import CategoryCashbookRel, Cashbook
from .ir import Rule
def register():
@ -13,4 +14,5 @@ def register():
Category,
Cashbook,
CategoryCashbookRel,
Rule,
module='cashbook_bookcategory', type_='model')

View file

@ -115,7 +115,7 @@
</record>
<record model="ir.rule" id="rg_category_rw_owner-1">
<field name="domain" eval="[
('create_uid.id', '=', Eval('user', {}).get('id', -1)),
('create_uid.id', '=', Eval('user_id', -1)),
]" pyson="1"/>
<field name="rule_group" ref="rg_category_rw_owner"/>
</record>

20
ir.py Normal file
View file

@ -0,0 +1,20 @@
# -*- 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 _context_modelnames(cls):
""" list of models to add 'user_id' to context
"""
return super(Rule, cls)._context_modelnames() + [
'cashbook.bookcategory']
# end Rule