Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2946 มุมมอง

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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ส.ค. 25
2333
2
มิ.ย. 23
3494
2
ก.ย. 22
4074
1
ส.ค. 23
2929
1
ก.ค. 23
3138