跳至内容
菜单
此问题已终结
1 回复
2969 查看

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.

形象
丢弃
最佳答案

Hello fudo,

You can achieve this by using search_read method,

Find Code in comment. 

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

形象
丢弃

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)

编写者

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

编写者

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.

相关帖文 回复 查看 活动
2
8月 25
2341
2
6月 23
3500
2
9月 22
4091
1
8月 23
2941
1
7月 23
3142