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

first of all  i new in odoo so maybe my question in very simple

i make a new rule :

name : personal contact

object : contact

domain filter : [('user_id','=',user.id)]
my purpose was that any user in each unit like sale's user or purchase's user couldn't access to any contact that any body make that.purchase dosen't access to customer info & sale dose not see vendor information .

after do this,my problem solved but i can't make RFQ or sale order ,and see this  error when i push Create Bottom  :

The requested operation ("read" on "Users" (res.users)) was rejected because of the following rules: (Records: False (id=2), User: False (id=2)) Implicitly accessed through 'Users' (res.users).

plz help me

Avatar
Discard
Best Answer

One problem is that the Contacts model (res.partner) stores information about users as well as customers and suppliers.  

Users can be identified with this domain: [["user_ids","!=",False]] 

So you should be able to change your domain to 

["|", ("user_ids","!=",False), ('user_id','=',user.id) ]

But if you want to prevent sales users from accessing vendors - and purchase users from accessing customers - your Record Rules need to be more complex.  My advice is to try some simpler examples to get more familiar with Odoo security rules.

Avatar
Discard
Author

thanks lot

i change domain as you say,but i see error when i want to create a new contact or RFQ or Sale Order

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

- personal contact

(Records: test1 (id=29), User: Administrator (id=2))

You can set the Record Rule not to apply for creation of Contacts (so it only applies to Read, Write and Delete).

This may help you: https://odootricks.tips/record-rules/

so helpful thank you Chris
my record rule domain
<field name="domain_force">['|',('user_id', '=', user.id),('user_ids','=',user.id)]</field>