Skip to Content
Menu
This question has been flagged

I am bilding an extension module of CRM. The problem is when a specific user is using the system to see only the Companies he has created. I am have tried a few things but still getting same access error (Document type: res.users, Operation: read)

The rule I have created is:

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

    <field name="name">Companies user had created</field>

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

    <field name="domain_force">[('user_id.id','=',user.id) ]</field>

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

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="True"/>

    <field name="perm_create" eval="True"/>

    <field name="perm_unlink" eval="False"/>

</record>

Avatar
Discard
Author Best Answer

I was missing a few rules in ir.model.access.csv and a condition in the force_domain>

here is my code:

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

<field name="name">Companies user had created</field>

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

<field name="domain_force">[('user_id.id','=',user.id),('user_id', '=', False) ]</field>

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

<field name="perm_read" eval="True"/>

<field name="perm_write" eval="True"/>

<field name="perm_create" eval="True"/>

<field name="perm_unlink" eval="False"/>

</record>


id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

lead,my.module.crm.lead,model_crm_lead,base.group_sale_salesman,1,1,1,0

mail_mailgate_thread_my_module,my.module.mail.thread,mail.model_mail_thread,base.group_sale_salesman,1,0,0,0

access_crm_payment_mode_user_my_module,my.module.crm.payment.mode,crm.model_crm_payment_mode,base.group_sale_salesman,1,0,0,0

access_crm_opportunity_report_user_my_module,my.module.crm.opportunity.report,crm.model_crm_opportunity_report,base.group_sale_salesman1,0,0,0

access_crm_tracking_campaign_user_my_moduleprinch.crm_tracking_campaign user,crm.model_crm_tracking_campaign,base.group_sale_salesman,1,0,0,0

access_res_partner_my_module,my.module.res.partner.crm.user,base.model_res_partner,base.group_sale_salesman1,1,1,0

access_res_partner_category_my_module,my.module.res.partner.category.crm.user,base.model_res_partner_category,base.group_sale_salesman,1,1,1,0

Avatar
Discard
Best Answer

This example i have tried, shos you for one employee connected its own payslips.

Try it by your self for your example.

Hope this can help you.

Regards.

Avatar
Discard

I shared an image but it doesnt appear :/

Related Posts Replies Views Activity
1
Aug 15
149
2
Mar 23
1639
1
Jan 17
3075
1
Feb 23
997
4
Dec 23
17033