Skip to Content
Menu
This question has been flagged
3 Replies
3138 Views

Hi Odoo community,

I have configured Odoo 12 for multi company and with global product catalog also. I need to create administrators for each of my companies but I dont want them to view or edit someone else's products. How can I do that? If I restrict access to the inventory the user can not see any product. If I give access as user or responsible he can view all the products. 

Do I have to create an access rule? How can I do that?


Please, I need help with this asap.


Thanks a lot,

Regards



Avatar
Discard
Best Answer

Use record rule.

This example is based on the 'responsible' field in product​

<record id="product_responsible_rule" model="ir.rule">
    <field name="name">Product Edit Access</field>
    <field name="model_id" ref="product.model_product_template"/>
    <field name="domain_force">[('responsible_id.id','=',user.id)]</field>
    <field name="perm_unlink" eval="False"/>
    <field name="perm_write" eval="False"/>
    <field name="perm_read" eval="True"/>
    <field name="perm_create" eval="False"/>
</record>


Avatar
Discard
Best Answer

Hi Cadorna,

It(Record Rule) will work based on your assigned companies.

<record id="product_template_rule" model="ir.rule">
<field name="name">Product Template</field>
<field name="model_id" ref="model_product_template"/>
<field name="domain_force">[('company_id', '=', user.company_id.id)]</field>
<field name="perm_unlink" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_read" eval="True"/>
<field name="perm_create" eval="False"/>
</record>

Thanks.

Avatar
Discard
Author Best Answer

Hi, 

Thanks for your help. Part of the solution worked fine: The different administrators of each company only are able to see and edit its own products and cannot view or edit any other item. The problema now is that when I navigate the web site of the company, no products are displayed. I guess this is happening because the rule is applying also on this section too and since a public user has no rights over any products, nothing is displayed.

Is there any way to avoid this from happening? Maybe making the rule being applied to the back-end only not on the public site. How can we achieve this?

Thanks in advance.


Regards





Avatar
Discard