Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1482 Vistas
how to limit access rights on Odoo so that salespeople can only access their own account data (such as contacts, discounts, etc.)


Avatar
Descartar
how to write the record rules of my problem

On Mon, Aug 7, 2023, 20:48 Nikhil Nakrani <notifications@mail.odoo.com> wrote:
A new answer on salesman access right has been posted. Click here to access the post : See post ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​

A new answer on salesman access right has been posted. Click here to access the post :

See post

--
Nikhil Nakrani


Odoo S.A.

+32 81 81 37 00 | info@odoo.com | https://www.odoo.com

Powered by Odoo
Mejor respuesta

Hi,

You can use record rules to achieve this.

eg: 

<record id="id_of_record" model="ir.rule">
        <field name="name">Record rule name</field>
        <field ref="sale.model_sale_order" name="model_id"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('module.your_user_group'))]"/>
        <field name="active" eval="False"/>
    </record>


The above shown code is an example of Record rule for only the user to view his own records and also the user should be in the group your_user_group.


We can add this from the front end also.


Go to Settings -> Technical -> Security -> Record Rules and create a rule.



Hope it helps

Avatar
Descartar
Mejor respuesta

Hi PT. Simpang Kopi Indonesia,

Please find code in comment. 

Hope it will be helpful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com 

Skype: kalpeshmaheshwari

Avatar
Descartar

Please find Example in comment :-

<record id="res_partner_salesperson" model="ir.rule">
<field name="name">res.partner.salesperson</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
</record>

In this record rule, we are checking for currently logged user(user.id) is salesperson in res.partner(customer/Contacts),

Now current logged user will see only that records of customer in which user is selected as salesperson (In res.partner salesperson field name is user_id)

Same this, you can create multiple record rules for different models(Just change reference model and domain).
Example of sale order:

<field name="model_id" ref="sale.model_sale.order"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>

Also in sale order, salesperson field's name is user_id