콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

I have several groups of users and one of those groups is 'group_reporter'. And this group can create requests and report it. While they create a new request it will be in 'Draft' stage and once they report it, it will be moved to 'Report'.

They should only be able to edit the request when it is in the 'Draft' stage. In the 'Report' stage it has to be in read-only state.

So I've written these two record rules:-

</record> -->
<!--
Name: Request Reporter - Edit
Group(s): group_reporter
Records: Incidents
Condition: if (user is owner of the record AND incident is in Draft stage)
Access Rights: Read/Write/Create
-->
<record id="rule_request_basic_reporter_edit" model="ir.rule">
<field name="name">Request Reporter - Edit</field>
<field name="model_id" ref="generic_request.model_request_request"/>
<field name="domain_force">[('created_by_id', '=', user.id), ('stage_type_name', '=', 'Draft')]</field>
<field name="groups" eval="[(4, ref('generic_request.group_reporter'))]"/>
<field eval="0" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

<!--
Name: Request Reporter - Edit
Group(s): group_reporter
Records: Incidents
Condition: if (user is owner of the record AND (incident is in Report stage))
Access Rights: Read-only
-->
<record id="rule_request_basic_reporter_read_only" model="ir.rule">
<field name="name">Request Reporter - Read-only</field>
<field name="model_id" ref="generic_request.model_request_request"/>
<field name="domain_force">[('created_by_id', '=', user.id),('stage_type_name', '=', 'Report')]</field>
<field name="groups" eval="[(4, ref('generic_request.group_reporter'))]"/>
<field eval="0" name="perm_unlink"/>
<field eval="0" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="0" name="perm_create"/>
</record>

But for some reason I am still able to edit the requests that are in 'Report' stage. I'm not sure what's wrong.

아바타
취소
베스트 답변

record rules will work as follows:

  1. The logical operation for global record (no groups) rules is 'AND' 
  2. The logical operation for groups record rules is 'OR'


아바타
취소
베스트 답변

It's difficult to offer advice without knowing the full setup, but is it possible that the users are members of another user access group that has access to this Model and the Record Rules (for that group) are less restrictive?

아바타
취소
베스트 답변

I haven't checked your code but sometimes the record rule apply only when you restart the server. The result actually stored in pre-cache and it will not apply instantly. 

아바타
취소
관련 게시물 답글 화면 활동
1
11월 24
1571
1
9월 24
1849
2
10월 22
11856
0
8월 21
2452
1
6월 19
4340