diff --git a/addons/sales_team/models/crm_team.py b/addons/sales_team/models/crm_team.py index 7d2ebac42c6..99333bc52c5 100644 --- a/addons/sales_team/models/crm_team.py +++ b/addons/sales_team/models/crm_team.py @@ -37,6 +37,9 @@ class CrmTeam(models.Model): team_id = default_team_id return team_id + def _get_default_favorite_user_ids(self): + return [(6, 0, [self.env.uid])] + name = fields.Char('Sales Channel', required=True, translate=True) active = fields.Boolean(default=True, help="If the active field is set to false, it will allow you to hide the sales channel without removing it.") company_id = fields.Many2one('res.company', string='Company', @@ -46,6 +49,14 @@ class CrmTeam(models.Model): string="Currency", readonly=True) user_id = fields.Many2one('res.users', string='Channel Leader') member_ids = fields.One2many('res.users', 'sale_team_id', string='Channel Members') + favorite_user_ids = fields.Many2many( + 'res.users', 'team_favorite_user_rel', 'team_id', 'user_id', + string='Favorite Members', + default=_get_default_favorite_user_ids) + is_favorite = fields.Boolean( + string='Show on dashboard', + compute='_compute_is_favorite', inverse='_set_is_favorite', + help="Favorite teams to display them in the dashboard and access them easily.") reply_to = fields.Char(string='Reply-To', help="The email address put in the 'Reply-To' of all emails sent by Odoo about cases in this sales channel") color = fields.Integer(string='Color Index', help="The color of the channel", default=1) @@ -80,6 +91,10 @@ class CrmTeam(models.Model): team.dashboard_graph_type = 'line' team.dashboard_graph_data = json.dumps(team._get_graph()) + def _compute_is_favorite(self): + for team in self: + team.is_favorite = self.env.user in team.favorite_user_ids + def _graph_get_dates(self, today): """ return a coherent start and end date for the dashboard graph according to the graph settings. """ @@ -259,4 +274,26 @@ class CrmTeam(models.Model): @api.model def create(self, values): - return super(CrmTeam, self.with_context(mail_create_nosubscribe=True)).create(values) + team = super(CrmTeam, self.with_context(mail_create_nosubscribe=True)).create(values) + if values.get('member_ids'): + team._add_members_to_favorites() + return team + + @api.multi + def write(self, values): + res = super(CrmTeam, self).write(values) + if values.get('member_ids'): + self._add_members_to_favorites() + return res + + @api.multi + def toggle_favorite(self): + sudoed_self = self.sudo() + to_fav = sudoed_self.filtered(lambda team: self.env.user not in team.favorite_user_ids) + to_fav.write({'favorite_user_ids': [(4, self.env.uid)]}) + (sudoed_self - to_fav).write({'favorite_user_ids': [(3, self.env.uid)]}) + return True + + def _add_members_to_favorites(self): + for team in self: + team.favorite_user_ids = [(4, member.id) for member in team.member_ids] diff --git a/addons/sales_team/security/sales_team_security.xml b/addons/sales_team/security/sales_team_security.xml index 904f7a3c04d..9e2e3f9939a 100644 --- a/addons/sales_team/security/sales_team_security.xml +++ b/addons/sales_team/security/sales_team_security.xml @@ -22,14 +22,6 @@ - - - Own Salesteam - - [('member_ids', 'in', user.id)] - - - All Salesteam diff --git a/addons/sales_team/static/src/js/sales_team_dashboard.js b/addons/sales_team/static/src/js/sales_team_dashboard.js index ea60d918259..ed961aa19b0 100644 --- a/addons/sales_team/static/src/js/sales_team_dashboard.js +++ b/addons/sales_team/static/src/js/sales_team_dashboard.js @@ -227,7 +227,7 @@ var SalesTeamDashboardView = KanbanView.extend({ }), display_name: _lt('Dashboard'), icon: 'fa-dashboard', - searchview_hidden: true, + searchview_hidden: false, }); view_registry.add('sales_team_dashboard', SalesTeamDashboardView); diff --git a/addons/sales_team/static/src/less/sales_team_dashboard.less b/addons/sales_team/static/src/less/sales_team_dashboard.less index 792317482de..db7ced8e487 100644 --- a/addons/sales_team/static/src/less/sales_team_dashboard.less +++ b/addons/sales_team/static/src/less/sales_team_dashboard.less @@ -11,6 +11,19 @@ @media (min-width: @screen-sm-min) { min-width: 450px; } + .o_dashboard_star { + font-size: 12px; + + &.fa-star-o { + color: @odoo-main-color-muted; + &:hover { + color: gold; + } + } + &.fa-star { + color: gold; + } + } .o_kanban_card_upper_content { margin-bottom: @odoo-horizontal-padding*2 + @o-kanban-progressbar-height + 85px; } @@ -194,4 +207,11 @@ &.o_kanban_nocontent .o_sales_dashboard { margin: 0; } + + &.o_kanban_grouped { + .o-flex-flow(row, wrap); + .o_kanban_record { + min-width: inherit; + } + } } diff --git a/addons/sales_team/views/crm_team_views.xml b/addons/sales_team/views/crm_team_views.xml index 73e34493902..a2d25ca0c38 100644 --- a/addons/sales_team/views/crm_team_views.xml +++ b/addons/sales_team/views/crm_team_views.xml @@ -26,7 +26,6 @@ - @@ -34,7 +33,7 @@ crm.team - + @@ -52,7 +51,7 @@ crm.team form kanban,form - {} + {'search_default_my_favorites': 1}

diff --git a/addons/sales_team/views/sales_team_dashboard.xml b/addons/sales_team/views/sales_team_dashboard.xml index a56bc78825b..7471a967ec8 100644 --- a/addons/sales_team/views/sales_team_dashboard.xml +++ b/addons/sales_team/views/sales_team_dashboard.xml @@ -11,6 +11,7 @@ +

@@ -67,6 +68,15 @@ Settings
+