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

Hello, I would like to limit some res.partner records visibility based on its value. For example I added `partner_type` field (selection string) to res.partner and I would like some group (for example sales_team.group_sale_salesman) to be able to see res.partner with value "partner_type = 'vendor'" only. but the limitation is only at the contacts module. How can I achieve this? 

I've tried adding rules like

            

   View vendor rule            

              

   [('partner_type','=','vendor')]            

               

           

But it doesn't seem to work.

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

Hello Zinedine Kahlil Gibran Zidane,

Please try below code it will help you

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

partner_type = fields.Selection([('vendor', 'Vendor')], string='Partner type')


@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self.env.user.has_group('sales_team.group_sale_salesman') and \
not self.env.user.has_group('sales_team.group_sale_manager') and \
not self.env.user.has_group('sales_team.group_sale_salesman_all_leads'):
domain += [('partner_type', '=','vendor')]
return super(ResPartner, self).search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order)

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
6459
0
thg 6 25
448
0
thg 1 25
1579
0
thg 1 25
1595
1
thg 12 24
2151