Skip to Content
Menu
This question has been flagged

Is this possible to do this by record rule?

Example:

user A have saleteam with member B,C,D. A is the leader of this team.

so if we login to A, and go to account.move, we can see records of A,B,C,D.

if we login to b, we only see B records.

Thanks you.

Note: Other solution are good too, no need to be record rule.

Avatar
Discard
Best Answer

Hello fudo,

You can achieve this by using search_read method,

Find Code in comment. 

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

Avatar
Discard

Create one group for Leader and try below code,

def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
teams = self.env['crm.team'].search([('user_id', '=', self.env.user.id)]).mapped('member_ids')
if self.env.user.has_group('account.group_account_manager') and self.env.user.has_group('new grop for leader'):
domain += ['|', ('invoice_user_id', 'in', teams.ids), ('invoice_user_id', '=', self.env.user.id)]
else:
domain += []
return super(AccountMove, self).search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order)

Author

thanks you for reply, i'll try this and response to you as soon as posible.

Author

thanks you sir, this solution was great, i was never know about search_read function before, this function can be use like record rule, even better.

Related Posts Replies Views Activity
2
Jun 23
2100
1
May 23
735
2
Sep 22
2503
1
Aug 23
1871
1
Jul 23
1973