Hi, you can achieve this simply by creating a compute field in 'crm.team' model and use this field in the sales team kanban view to filter the teams so that a user can see only his teami.e,in your .py file,
_inherit = 'crm.team'
current_team_status = fields.Boolean(string="current user", compute='get_team')
@api.multi def get_team(self):
u_id = self.env['res.users'].browse(self._uid)
for rec in self:
rec.current_team_status = False
if u_id.has_group('base.group_sale_salesman_all_leads') and u_id.has_group( 'base.group_sale_salesman') and u_id.has_group('base.group_sale_manager'):
for rec in self:
rec.current_team_status = True
elif u_id.has_group('base.group_sale_salesman_all_leads') and u_id.has_group('base.group_sale_salesman'):
teams = self.search(['|', ('parent_team.user_id.id', '=', u_id.id), ('user_id.id', '=', u_id.id)])
for team in teams:
team.current_team_status = True
elif u_id.has_group('base.group_sale_salesman'):
team = self.browse([u_id.sale_team_id.id])
team.current_team_status = True
and in your xml file,
<record model="ir.ui.view" id="sales_team_kanban_view_in_crm_bs">
<field name="name">crm.team.kanban</field>
<field name="model">crm.team</field>
<field name="inherit_id" ref="sales_team.crm_team_salesteams_view_kanban"/>
<field name="arch" type="xml">
<xpath expr="//sales_team_dashboard/templates/t/div[1]" position="inside">
<field name="current_team_status" invisible="1"/>
</xpath>
<xpath expr="//sales_team_dashboard/templates/t/div[1]" position="attributes">
<attribute name="attrs">{'invisible':[('current_team_status', '!=', True)]}</attribute>
</xpath>
</field>
</record>
Now the admin can see all the teams in dashboard and the user can only see his team.
Hope this will help
thank you