Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

-1

How do I let all users see all leads (read only) but edit only the leads in the user group they belong to (read / write) ?

By
Ossama Gharib
on 8/6/15, 12:38 PM 520 views

In Leads TreeView and FormView, I want to allow one user group to:

- View-only all leads' records (in TreeView)

- Edit the records owned by such user group (in FormView)

I have tried to find a way by using the ir.model.access.csv or ir.rule, but could not find any way.

AFAIK, I am not able to list all leads, and at the same time: allow some leads to be view-only and some other leads to be editable.

How can I list (view-only) all the records (in TreeView) but allow some of those records to be editable?

0
Ossama Gharib
On 8/19/15, 5:35 AM

I got the answer. It is easy to achieve this goal.

Create two record rules as follows (in your views XML file, where "group_sales_base" is the user group that the rules would be applied to):

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

    <field name="name">Personal Leads</field>

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

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

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

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

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

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

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

</record>

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

    <field name="name">Others' Leads</field>

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

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

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

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

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

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

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

</record> 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/6/15, 12:38 PM
Seen: 520 times
Last updated: 8/19/15, 10:21 AM