تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
1670 أدوات العرض

Hi,

In our company we have a external  sales man, therefore he has to see only the contacts  in odoo which  was created by him. I tried it with the  record rule  [("create_uid", "=", user.id)] but however I  get  the following error, still I can close this error and proceed. but the  error pop up comes  often.


because  the followers in contact app  are related  to  res.user eventhough the follower  is he himself.  Anyhelp  would be appreciated . Thanks  

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

['|', '|',

('create_uid', '=', user.partner_id.id),

]


For now  got  this working with the above code, but the user  gets error when he opens  a  contact where he  is  a follower assigned by some one in res.partner.  Is  there a way  to  handle this case as well,  where  the user can see the contact where he a follower  and along with it he has access to  the one who created  that contact or  all the followers  of that contact.

الصورة الرمزية
إهمال
أفضل إجابة

The issue arises because the record rule you applied restricts access based on the create_uid, but certain actions (like adding followers) attempt to fetch related data (e.g., followers) that are not covered by the rule. This inconsistency leads to the error.


Here’s how you can fix it:


Solution: Adjust Record Rule and Consider Followers

1. Modify the Record Rule

The record rule [("create_uid", "=", user.id)] is too restrictive in this case because it doesn’t account for the linked followers model. You need to extend the rule to include records where the user is either the creator or a follower.


Adjusted Rule (Python):


[("|", ("create_uid", "=", user.id), ("message_partner_ids", "in", [user.partner_id.id]))]


Clear Cache and restart Server

الصورة الرمزية
إهمال
الكاتب

Hi,
I tried it but i get thefollowing errorwhen trying to save the record rule
Validation error

Invalid domain: Invalid field res.partner.| in leaf (‘|’, (‘create_uid’, ‘=’, 100), (‘message_partner_ids’, ‘in’, [5589]))

There is a small typo but the appraoch is correct
try
['|',("create_uid", "=", user.id),('message_partner_ids','in', [user.partner_id.id])]

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أبريل 25
2053
2
يناير 24
3638
0
يناير 24
1816
0
ديسمبر 20
2332
1
سبتمبر 19
5171