Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3558 Lượt xem

Let's say I have a model employee.category for which I have created a rule for a group A.

Users from group A shouldn't see all the records when they enter a menu that shows the employee.category records. (This I have achieved using the rule)

The problem is, I have employee.category as a Many2one field in another model's form view, and the users from group A can't see all the records of the Many2one (because the rule is global), is there any way for me to make the rule only work when consulting the menu of employee.category and not when seeing the Many2one records in another model's form view ?


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thanks @Niyas Raphy solution worked.

Ảnh đại diện
Huỷ bỏ

Karsa, can you tell me how the proposed solution worked with you?

Câu trả lời hay nhất

Hi,

For this case instead of adding the record rule, you can apply the domain by inheriting the _search method. If you need to apply the filteration in some place only, you can control it by passing some keys in the context. See an example,

@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
# TDE FIXME: strange
if self._context.get('search_default_categ_id'):
args.append((('categ_id', 'child_of', self._context['search_default_categ_id'])))
return super(ProductProduct, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 25
6006
1
thg 12 24
1527
2
thg 11 24
1737
1
thg 11 22
16089
3
thg 8 22
13170