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/dispatcher.py”, 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/modelview.py”, 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/apar.py”, line 74, in submit
EmployeeForm.submit_to_hod(record.employee_forms)
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/modelview.py”, 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/apar.py”, line 315, in submit_to_hod
cls.submit([record])
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/model/workflow.py”, 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/modelsql.py”, 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/modelsql.py”, 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/modelsql.py”, line 1160, in __check_domain_rule
cls.raise_user_error(‘access_error’, cls.name)
File “/opt/tryton/tryton50/lib/python3.6/site-packages/trytond-5.0.3-py3.6.egg/trytond/error.py”, 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 - https://github.com/tryton/trytond/commit/6b06e3221d527210f9b8ab414b245bfe16926bb3)