From b8bb700364ec16a889f4fda7d8af0a792ac17980 Mon Sep 17 00:00:00 2001 From: Nikunj Ladava Date: Wed, 1 Jun 2022 09:35:24 +0000 Subject: [PATCH] [IMP] sales_team: display empty sales teams on members' kanban view When we open the 'CRM > Configuration > Team Members' menu, if there are no members in any of the teams, we see the empty screen(no dummy data, no action helper), which looks a bit ugly. This commit improves the behavior by displaying all the (accessible) sales teams, even if they are empty. So, even if there are no members available, we will get to see the dummy data and action helper. Note that in the data, we already have one sales team available, so this should be okay. But if someone intentionally removes all the teams, it will still lead to an empty ugly screen. Since this is a rare case, we haven't considered it for now. task-2583755 Part-of: odoo/odoo#92616 --- addons/sales_team/models/crm_team_member.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/sales_team/models/crm_team_member.py b/addons/sales_team/models/crm_team_member.py index 9ba61aad5d1..6fc967661bf 100644 --- a/addons/sales_team/models/crm_team_member.py +++ b/addons/sales_team/models/crm_team_member.py @@ -13,7 +13,7 @@ class CrmTeamMember(models.Model): _check_company_auto = True crm_team_id = fields.Many2one( - 'crm.team', string='Sales Team', + 'crm.team', string='Sales Team', group_expand='_read_group_crm_team_id', default=False, # TDE: temporary fix to activate depending computed fields check_company=True, index=True, ondelete="cascade", required=True) user_id = fields.Many2one( @@ -179,6 +179,13 @@ class CrmTeamMember(models.Model): ]) return super(CrmTeamMember, self).write(values) + @api.model + def _read_group_crm_team_id(self, teams, domain, order): + """Read group customization in order to display all the teams in + Kanban view, even if they are empty. + """ + return self.env['crm.team'].search([], order=order) + def _synchronize_memberships(self, user_team_ids): """ Synchronize memberships: archive other memberships.