Skip to Content
Menu
This question has been flagged
1 Reply
1650 Views

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.

Avatar
Discard
Best Answer

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


Avatar
Discard
Related Posts Replies Views Activity
1
Mar 15
5511
0
Dec 24
56
0
May 24
249
1
Dec 23
1093
0
Dec 23
310