From 4c2db92aecc10103d2c8ef0269d342d20b61e979 Mon Sep 17 00:00:00 2001 From: "Pierre Collinet (pic)" Date: Thu, 11 Jun 2020 08:46:25 +0000 Subject: [PATCH] [IMP] crm_iap_lead: improve onboarding tour of module crm_iap_lead - Improve crm onboarding tour text messages and display - Modify CRMLeadMiningRequest to improve the Lead Generation Process Default value for lead_number changes from 10 to 3; Computed value for team_id : per default add the current user sale_team_id; Default value for user_id : per default add the current user; Default values for country_ids : Per default, add the country of the active company because it avoids a click and is usually correct; - Improve crm_iap_lead_mining_request_form Group fields by sections for more readability; Change string attribute of some fields; Change the position of the alert messages to the top of the form (as a ribbon); Change button string from Submit to Generate Leads to be more explicit; Task ID 2226563 Community PR #51587 Signed-off-by: Thibault Delavallee (tde) --- .../models/crm_iap_lead_mining_request.py | 22 ++++- .../static/src/js/tours/crm_iap_lead.js | 41 ++++++++ .../views/crm_iap_lead_templates.xml | 3 +- .../crm_iap_lead/views/crm_iap_lead_views.xml | 95 ++++++++----------- 4 files changed, 100 insertions(+), 61 deletions(-) create mode 100644 addons/crm_iap_lead/static/src/js/tours/crm_iap_lead.js diff --git a/addons/crm_iap_lead/models/crm_iap_lead_mining_request.py b/addons/crm_iap_lead/models/crm_iap_lead_mining_request.py index 6f30f596d2a..8cd41ebb3bd 100644 --- a/addons/crm_iap_lead/models/crm_iap_lead_mining_request.py +++ b/addons/crm_iap_lead/models/crm_iap_lead_mining_request.py @@ -12,6 +12,7 @@ _logger = logging.getLogger(__name__) DEFAULT_ENDPOINT = 'https://iap-services.odoo.com' MAX_LEAD = 200 + MAX_CONTACT = 5 CREDIT_PER_COMPANY = 1 @@ -28,19 +29,25 @@ class CRMLeadMiningRequest(models.Model): else: return 'opportunity' + def _default_country_ids(self): + return self.env.user.company_id.country_id + name = fields.Char(string='Request Number', required=True, readonly=True, default=lambda self: _('New'), copy=False) state = fields.Selection([('draft', 'Draft'), ('done', 'Done'), ('error', 'Error')], string='Status', required=True, default='draft') # Request Data - lead_number = fields.Integer(string='Number of Leads', required=True, default=10) + lead_number = fields.Integer(string='Number of Leads', required=True, default=3) search_type = fields.Selection([('companies', 'Companies'), ('people', 'Companies and their Contacts')], string='Target', required=True, default='companies') error = fields.Text(string='Error', readonly=True) # Lead / Opportunity Data + lead_type = fields.Selection([('lead', 'Leads'), ('opportunity', 'Opportunities')], string='Type', required=True, default=_default_lead_type) display_lead_label = fields.Char(compute='_compute_display_lead_label') - team_id = fields.Many2one('crm.team', string='Sales Team', domain="[('use_opportunities', '=', True)]") - user_id = fields.Many2one('res.users', string='Salesperson') + team_id = fields.Many2one( + 'crm.team', string='Sales Team', + domain="[('use_opportunities', '=', True)]", readonly=False, compute='_compute_team_id', store=True) + user_id = fields.Many2one('res.users', string='Salesperson', default=lambda self: self.env.user) tag_ids = fields.Many2many('crm.tag', string='Tags') lead_ids = fields.One2many('crm.lead', 'lead_mining_request_id', string='Generated Lead / Opportunity') lead_count = fields.Integer(compute='_compute_lead_count', string='Number of Generated Leads') @@ -49,12 +56,12 @@ class CRMLeadMiningRequest(models.Model): filter_on_size = fields.Boolean(string='Filter on Size', default=False) company_size_min = fields.Integer(string='Size', default=1) company_size_max = fields.Integer(default=1000) - country_ids = fields.Many2many('res.country', string='Countries') + country_ids = fields.Many2many('res.country', string='Countries', default=_default_country_ids) state_ids = fields.Many2many('res.country.state', string='States') industry_ids = fields.Many2many('crm.iap.lead.industry', string='Industries') # Contact Generation Filter - contact_number = fields.Integer(string='Number of Contacts', default=1) + contact_number = fields.Integer(string='Number of Contacts', default=10) contact_filter_type = fields.Selection([('role', 'Role'), ('seniority', 'Seniority')], string='Filter on', default='role') preferred_role_id = fields.Many2one('crm.iap.lead.role', string='Preferred Role') role_ids = fields.Many2many('crm.iap.lead.role', string='Other Roles') @@ -98,6 +105,11 @@ class CRMLeadMiningRequest(models.Model): for request in self: request.lead_count = mapped_data.get(request.id, 0) + @api.depends('user_id') + def _compute_team_id(self): + for record in self: + record.team_id = record.user_id.sale_team_id + @api.onchange('lead_number') def _onchange_lead_number(self): if self.lead_number <= 0: diff --git a/addons/crm_iap_lead/static/src/js/tours/crm_iap_lead.js b/addons/crm_iap_lead/static/src/js/tours/crm_iap_lead.js new file mode 100644 index 00000000000..577b6cd14d9 --- /dev/null +++ b/addons/crm_iap_lead/static/src/js/tours/crm_iap_lead.js @@ -0,0 +1,41 @@ +odoo.define('crm_iap_lead.generate_leads_steps', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); +var core = require('web.core'); + +require('crm.tour'); +var _t = core._t; + +var DragOppToWonStepIndex = _.findIndex(tour.tours.crm_tour.steps, function (step) { + return (step.id === 'drag_opportunity_to_won_step'); +}); + +tour.tours.crm_tour.steps.splice(DragOppToWonStepIndex + 1, 0, { + /** + * Add some steps between "Drag your opportunity to Won when you get + * the deal. Congrats !" and "Let’s have a look at an Opportunity." to + * include the steps related to the lead generation (crm_iap_lead). + * This eases the on boarding for the Lead Generation process. + * + */ + trigger: ".o_button_generate_leads", + content: _t("Looking for more opportunities ?
Try the Lead Generation tool."), + position: "bottom", + run: function (actions) { + actions.auto('.o_button_generate_leads'); + }, +}, { + trigger: '.modal-body .o_industry', + content: _t("Which Industry do you want to target?"), + position: "right", +}, { + trigger: '.modal-footer button[name=action_submit]', + content: _t("Now, just let the magic happen!"), + position: "bottom", + run: function (actions) { + actions.auto('.modal-footer button[special=cancel]'); +} +}); + +}); \ No newline at end of file diff --git a/addons/crm_iap_lead/views/crm_iap_lead_templates.xml b/addons/crm_iap_lead/views/crm_iap_lead_templates.xml index d6844a6a242..107a1140026 100644 --- a/addons/crm_iap_lead/views/crm_iap_lead_templates.xml +++ b/addons/crm_iap_lead/views/crm_iap_lead_templates.xml @@ -3,6 +3,7 @@ - + \ No newline at end of file diff --git a/addons/crm_iap_lead/views/crm_iap_lead_views.xml b/addons/crm_iap_lead/views/crm_iap_lead_views.xml index 5621f10109e..e1a967d71b2 100644 --- a/addons/crm_iap_lead/views/crm_iap_lead_views.xml +++ b/addons/crm_iap_lead/views/crm_iap_lead_views.xml @@ -6,25 +6,19 @@
-
- -
- - - - - - - - - - - + +

What do you need ?

+ + + +
+ + + +
+ - + + + + - - - - - - + + + + + -
-
- + + +
+ + Extra contacts per Company
-
- -
-
+ + + + + + + + +