diff --git a/addons/sales_team/__manifest__.py b/addons/sales_team/__manifest__.py index 39fae18b93c..d856467e068 100644 --- a/addons/sales_team/__manifest__.py +++ b/addons/sales_team/__manifest__.py @@ -1,26 +1,30 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + { 'name': 'Sales Teams', 'version': '1.0', 'category': 'Sales/Sales', 'summary': 'Sales Teams', 'description': """ -Using this application you can manage Sales Teams with CRM and/or Sales -=========================================================================== +Using this application you can manage Sales Teams with CRM and/or Sales +======================================================================= """, 'website': 'https://www.odoo.com/page/crm', 'depends': ['base', 'mail'], - 'data': ['security/sales_team_security.xml', - 'security/ir.model.access.csv', - 'data/sales_team_data.xml', - 'views/crm_team_views.xml', - 'views/sales_team_dashboard.xml', - 'views/crm_tag_views.xml', - ], - 'demo': ['data/sales_team_demo.xml', - 'data/crm_tag_demo.xml', - ], + 'data': [ + 'security/sales_team_security.xml', + 'security/ir.model.access.csv', + 'data/crm_team_data.xml', + 'views/assets.xml', + 'views/crm_tag_views.xml', + 'views/crm_team_views.xml', + 'views/mail_activity_views.xml', + ], + 'demo': [ + 'data/crm_team_demo.xml', + 'data/crm_tag_demo.xml', + ], 'installable': True, 'auto_install': False, } diff --git a/addons/sales_team/data/crm_tag_demo.xml b/addons/sales_team/data/crm_tag_demo.xml index 4b409e0bf27..85d61b063ea 100644 --- a/addons/sales_team/data/crm_tag_demo.xml +++ b/addons/sales_team/data/crm_tag_demo.xml @@ -1,39 +1,38 @@ - - + - - - Product - - - - Software - - - - Services - - - - Information - - - - Design - - - - Training - - - - Consulting - - - - Other - - - - + + + Product + + + + Software + + + + Services + + + + Information + + + + Design + + + + Training + + + + Consulting + + + + Other + + + + diff --git a/addons/sales_team/data/sales_team_data.xml b/addons/sales_team/data/crm_team_data.xml similarity index 100% rename from addons/sales_team/data/sales_team_data.xml rename to addons/sales_team/data/crm_team_data.xml diff --git a/addons/sales_team/data/sales_team_demo.xml b/addons/sales_team/data/crm_team_demo.xml similarity index 100% rename from addons/sales_team/data/sales_team_demo.xml rename to addons/sales_team/data/crm_team_demo.xml diff --git a/addons/sales_team/models/crm_team.py b/addons/sales_team/models/crm_team.py index 4b84837c506..ef919653fea 100644 --- a/addons/sales_team/models/crm_team.py +++ b/addons/sales_team/models/crm_team.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. - -from babel.dates import format_date -from datetime import date, datetime -from dateutil.relativedelta import relativedelta import json +from babel.dates import format_date +from datetime import date +from dateutil.relativedelta import relativedelta + from odoo import api, fields, models, _ -from odoo.exceptions import AccessError, UserError +from odoo.exceptions import UserError from odoo.release import version -from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF class CrmTeam(models.Model): @@ -38,32 +37,29 @@ class CrmTeam(models.Model): name = fields.Char('Sales Team', required=True, translate=True) sequence = fields.Integer('Sequence', default=10) active = fields.Boolean(default=True, help="If the active field is set to false, it will allow you to hide the Sales Team without removing it.") - company_id = fields.Many2one('res.company', string='Company', - default=lambda self: self.env.company, index=True) + company_id = fields.Many2one( + 'res.company', string='Company', index=True, + default=lambda self: self.env.company) currency_id = fields.Many2one( - "res.currency", related='company_id.currency_id', - string="Currency", readonly=True) + "res.currency", string="Currency", + related='company_id.currency_id', readonly=True) user_id = fields.Many2one('res.users', string='Team Leader', check_company=True) + # memberships member_ids = fields.One2many( - 'res.users', 'sale_team_id', string='Channel Members', check_company=True, - domain=[('share', '=', False)], + 'res.users', 'sale_team_id', string='Channel Members', + check_company=True, domain=[('share', '=', False)], help="Add members to automatically assign their documents to this sales team. You can only be member of one team.") + # UX options + color = fields.Integer(string='Color Index', help="The color of the channel") favorite_user_ids = fields.Many2many( 'res.users', 'team_favorite_user_rel', 'team_id', 'user_id', - string='Favorite Members', - default=_get_default_favorite_user_ids) + string='Favorite Members', default=_get_default_favorite_user_ids) is_favorite = fields.Boolean( - string='Show on dashboard', - compute='_compute_is_favorite', inverse='_inverse_is_favorite', + string='Show on dashboard', compute='_compute_is_favorite', inverse='_inverse_is_favorite', help="Favorite teams to display them in the dashboard and access them easily.") - color = fields.Integer(string='Color Index', help="The color of the channel") dashboard_button_name = fields.Char(string="Dashboard Button", compute='_compute_dashboard_button_name') dashboard_graph_data = fields.Text(compute='_compute_dashboard_graph') - def _compute_dashboard_graph(self): - for team in self: - 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 @@ -75,6 +71,65 @@ class CrmTeam(models.Model): (sudoed_self - to_fav).write({'favorite_user_ids': [(3, self.env.uid)]}) return True + def _compute_dashboard_button_name(self): + """ Sets the adequate dashboard button name depending on the Sales Team's options + """ + for team in self: + team.dashboard_button_name = _("Big Pretty Button :)") # placeholder + + def _compute_dashboard_graph(self): + for team in self: + team.dashboard_graph_data = json.dumps(team._get_dashboard_graph_data()) + + # ------------------------------------------------------------ + # CRUD + # ------------------------------------------------------------ + + @api.model + def create(self, 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 + + def write(self, values): + res = super(CrmTeam, self).write(values) + if values.get('member_ids'): + self._add_members_to_favorites() + return res + + def unlink(self): + default_teams = [ + self.env.ref('sales_team.salesteam_website_sales'), + self.env.ref('sales_team.pos_sales_team'), + self.env.ref('sales_team.ebay_sales_team') + ] + for team in self: + if team in default_teams: + raise UserError(_('Cannot delete default team "%s"' % (team.name))) + return super(CrmTeam,self).unlink() + + # ------------------------------------------------------------ + # ACTIONS + # ------------------------------------------------------------ + + def action_primary_channel_button(self): + """ Skeleton function to be overloaded It will return the adequate action + depending on the Sales Team's options. """ + return False + + # ------------------------------------------------------------ + # TOOLS + # ------------------------------------------------------------ + + def _add_members_to_favorites(self): + for team in self: + team.favorite_user_ids = [(4, member.id) for member in team.member_ids] + + # ------------------------------------------------------------ + # GRAPH + # ------------------------------------------------------------ + def _graph_get_model(self): """ skeleton function defined here because it'll be called by crm and/or sale """ @@ -146,7 +201,7 @@ class CrmTeam(models.Model): self._cr.execute(query, [self.id, start_date, end_date] + where_clause_params) return self.env.cr.dictfetchall() - def _get_graph(self): + def _get_dashboard_graph_data(self): def get_week_name(start_date, locale): """ Generates a week name (string) from a datetime according to the locale: E.g.: locale start_date (datetime) return string @@ -183,43 +238,3 @@ class CrmTeam(models.Model): [graph_title, graph_key] = self._graph_title_and_key() color = '#875A7B' if '+e' in version else '#7c7bad' return [{'values': values, 'area': True, 'title': graph_title, 'key': graph_key, 'color': color}] - - def _compute_dashboard_button_name(self): - """ Sets the adequate dashboard button name depending on the Sales Team's options - """ - for team in self: - team.dashboard_button_name = _("Big Pretty Button :)") # placeholder - - def action_primary_channel_button(self): - """ skeleton function to be overloaded - It will return the adequate action depending on the Sales Team's options - """ - return False - - @api.model - def create(self, 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 - - def write(self, values): - res = super(CrmTeam, self).write(values) - if values.get('member_ids'): - self._add_members_to_favorites() - return res - - def unlink(self): - default_teams = [ - self.env.ref('sales_team.salesteam_website_sales'), - self.env.ref('sales_team.pos_sales_team'), - self.env.ref('sales_team.ebay_sales_team') - ] - for team in self: - if team in default_teams: - raise UserError(_('Cannot delete default team "%s"' % (team.name))) - return super(CrmTeam,self).unlink() - - 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/models/res_users.py b/addons/sales_team/models/res_users.py index 0714af03dce..f2fdd18337a 100644 --- a/addons/sales_team/models/res_users.py +++ b/addons/sales_team/models/res_users.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import fields, models class ResUsers(models.Model): diff --git a/addons/sales_team/views/assets.xml b/addons/sales_team/views/assets.xml new file mode 100644 index 00000000000..3331b7cf4c1 --- /dev/null +++ b/addons/sales_team/views/assets.xml @@ -0,0 +1,8 @@ + + + + diff --git a/addons/sales_team/views/crm_team_views.xml b/addons/sales_team/views/crm_team_views.xml index 008a40f7d0c..f495e5cd62d 100644 --- a/addons/sales_team/views/crm_team_views.xml +++ b/addons/sales_team/views/crm_team_views.xml @@ -1,182 +1,244 @@ - - + - - - Sales Teams - Search - crm.team - - - - - - - - - - - + + Sales Teams - Search + crm.team + + + + + + + + + + + - - - Sales Teams - crm.team - kanban,form - - {'in_sales_app': True} - -

- Define a new sales team -

- Use Sales Teams to organize your sales departments. - Each team will work with a separate pipeline. -

-
-
- - - Team Pipelines - crm.team - kanban,form - - {} - -

- Define a new sales team -

- Use Sales Teams to organize your sales departments. - Each team will work with a separate pipeline. -

-
-
- - - - - crm.team.form - crm.team - -
- -
- -
-