Skip to Content
Menu
This question has been flagged
3 Replies
2944 Views

I have installed Version 9.0c-20170301 (Community Edition)

any sales-users can see other teams pipeline at sales dashboard

the user is granted see own leads but they still can see other teams pipeline at the dashboard

Example: User x is a member at sales team "direct-sales" and checked "See Own Leads" but he can see at sales dashboard all other teams Pipeline for the same company. I need to configure the user to see only his pipeline at the dashboard

how to fix this

Avatar
Discard
Author Best Answer

Thank you @linto

can you provide me with screen shoot how to do this

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

Give server action for the menu item and try. from server action return only required datas to the view

Avatar
Discard