コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2261 ビュー

For my Odoo, I need to restrict the access to the contact module. I already created a user group which won't be able to access any contacts (even with the proper url, they'll get an access error for any contact). 

What I now need is a specific filter that they can access their own contact.

Anyone could help on how the record rule syntax should be structured?

アバター
破棄

Hello Jan Fischer,

I also faced same issue and found one solution that's working for me. I hope it work's for you also. No need to write record rule for this.

Please try below steps:

Step 1:- Create New group, that is already created by you. By providing this group to the user will only able to see own contacts only.

<record id="group_id" model="res.groups">
<field name="name">User: Own Contacts Only</field>
<field name="category_id" ref="category_name"/>
</record>

Step 2:- Write Search method,
py file

from odoo import models

class ResPartner(models.Model):
_inherit = "res.partner"

def search(self, args, **kwargs):
"""
Write Search Method for Partner to filter own contacts only
"""
if self.env.user.has_group('module_name.group_id'):
args += [('user_id', '=', self.env.user.id)]
return super(ResPartner, self).search(args, **kwargs)

Note:- user_id is a field under Sales & Purchase tab in res.partner view and string is Salesperson.

Step 3:- Create User and provide User: Own Contacts Only access rights as well provide Salesperson at partner level. User Own Contacts Only is filtered based on Salesperson.

最善の回答
Hello Jan Fischer,

I also faced same issue and found one solution that's working for me. I hope it work's for you also. No need to write record rule for this.

Please try below steps:

Step 1:- Create New group, that is already created by you. By providing this group to the user will only able to see own contacts only.


User: Own Contacts Only



Step 2:- Write Search method,
py file

from odoo import models


class ResPartner(models.Model):
_inherit = "res.partner"


def search(self, args, **kwargs):
"""
Write Search Method for Partner to filter own contacts only
"""
if self.env.user.has_group('module_name.group_id'):
args += [('user_id', '=', self.env.user.id)]
return super(ResPartner, self).search(args, **kwargs)

Note:- user_id is a field under Sales & Purchase tab in res.partner view and string is Salesperson.

Step 3:- Create User and provide User: Own Contacts Only access rights as well provide Salesperson at partner level. User Own Contacts Only is filtered based on Salesperson.
アバター
破棄
関連投稿 返信 ビュー 活動
2
5月 25
1190
1
11月 23
1970
1
7月 24
1658
0
6月 24
1569
4
12月 23
24260