Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4733 Widoki

Hello. Please help me. I have project and I have created a record rule for sales/user: own document only group. I set the domain filter to [('userd_id','=', user.id)] so that they can only see the record that is being assigned to them in contacts. 

<record model="ir.rule" id="partner_view_rule_salesperson">
<field name="name">Sales Person View Rule</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="groups" eval="[(4, ref('sales_team.group_sale_salesman'))]" />
<field name="domain_force">[('user_id', '=', user.id)]</field>
</record>


Now the problem is, it also affect the administrator group


The requested operation ("create" on "Contact" (res.partner)) was rejected because of the following rules: - Sales Person View Rule 


(Records: Sample code (id=16), User: Administrator (id=2))

I got the error when I create a new user, which is a bit confusing because I only assigned that record rule for sales/user: own document only group. If I remove the record rule that I created, It returns normal.

I hope anyone can help me with this. I have been searching on every odoo guide on google but the problem still persist. Sorry for my bad english as it is not my first language. Thank you!

 

Awatar
Odrzuć
Najlepsza odpowiedź
Hi
try this
add this rule along with your rule

<record model="ir.rule" id="partner_view_rule_salesperson_global">
<field name="name">Sales Person View Global</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="domain_force">[(1, '=', 1)]</field>
</record>
You may add groups also for getting full access for respective group

for manager in sales
  <field name="groups" eval="[(4, ref('sales_team.group_sale_manager'))]"/>

for Administrator only
<field name="groups" eval="[(4, ref('base.group_erp_manager'))]"/>
Awatar
Odrzuć
Autor

Hello Murad PP, thanks for the quick response, unfortunately it still doesn't solve the problem. it's still throwing the same error.

The requested operation ("create" on "Contact" (res.partner)) was rejected because of the following rules:

- Sales Person View Rule

(Records: Sample code (id=18), User: Administrator (id=2))

have you tried with group, it will work

<record model="ir.rule" id="partner_view_rule_salesperson_global">

<field name="name">Sales Person View Global</field>

<field name="model_id" ref="base.model_res_partner"/>

<field name="groups" eval="[(4, ref('sales_team.group_sale_manager'))]"/>

<field name="domain_force">[(1, '=', 1)]</field>

</record>

Autor

Thank you bro! You really helped me. It works with group in it!. God bless brother.

Powiązane posty Odpowiedzi Widoki Czynność
0
maj 17
2615
1
gru 24
957
0
wrz 22
2280
1
wrz 22
1295
0
sie 22
722