콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3029 화면

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
2378
2
6월 23
3543
2
9월 22
4139
1
8월 23
2983
1
7월 23
3206