Checking access rule after modification

Hi there,

Scenario -
I have 2 users roles (res.groups) working on the same record let us say group1 and group2. A user of group1 changes the state of the record through workflow the transition, and the record should become readonly for that user.

A record rule is written for the same, that when state is draft, the record should be writable and is assigned to group1 role.

Problem -
When pressing the button, the transition changes the state from draft to submit. On doing this, the system checks for record rules once again. This creates an error.

Traceback (most recent call last):
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/protocols/”, line 176, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/”, line 665, in wrapper
return func(cls, records, *args, **kwargs)
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond_apar-5.0.0-py3.6.egg/trytond/modules/apar/”, line 74, in submit
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/”, line 665, in wrapper
return func(cls, records, *args, **kwargs)
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond_apar-5.0.0-py3.6.egg/trytond/modules/apar/”, line 315, in submit_to_hod
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/”, line 43, in wrapper
cls._transition_state: state,
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/”, line 147, in wrapper
return func(cls, *args, **kwargs)
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/”, line 998, in write
cls.__check_domain_rule(all_ids, ‘write’)
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/”, line 1160, in __check_domain_rule
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/”, line 74, in raise_user_error
raise UserError(error)

trytond.exceptions.UserError: (‘UserError’, (‘You try to bypass an access rule.\n(Document type: apar.employee.form)’, ‘’))

There is a commit that corresponds to that change. I do not know the real reason behind this, but in my opinion, checking for record rule after writing the record raises another level of problems. (Ref -

Could you explain which rules are defined on the database for the model?

I defined a simple rule:

[[“state”, “in”, [“draft”]]]

Initially, when the state is in draft, Tryton gets the record and changes the state from draft to submitted. Once it is submitted, then it checks for the rule again and fails.

On my system, if I comment out the line, then it works fine.

It is because we want that changes made by a user, can be reverted by the user.

Indeed workflow transition is done with buttons so the access rights are not enforced when executing the code of the button. But the record rules are excluded from this pattern and always enforced until Issue 4080: Remove company record rules - Tryton issue tracker is solved.

So I guess, we will have to comment out the line that checks the rule again and go ahead with our installation.

The only way to skip record rule for now, is to switch to user root (id=0).