diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/crm_iap_lead/static/src | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/crm_iap_lead/static/src')
3 files changed, 138 insertions, 0 deletions
diff --git a/addons/crm_iap_lead/static/src/js/leads_tree_generate_leads.js b/addons/crm_iap_lead/static/src/js/leads_tree_generate_leads.js new file mode 100644 index 00000000..7db2d99e --- /dev/null +++ b/addons/crm_iap_lead/static/src/js/leads_tree_generate_leads.js @@ -0,0 +1,76 @@ +odoo.define('crm.leads.tree', function (require) { +"use strict"; + var ListController = require('web.ListController'); + var ListView = require('web.ListView'); + + var KanbanController = require('web.KanbanController'); + var KanbanView = require('crm.crm_kanban').CrmKanbanView; + + var viewRegistry = require('web.view_registry'); + + function renderGenerateLeadsButton() { + if (this.$buttons) { + var self = this; + var lead_type = self.initialState.getContext()['default_type']; + this.$buttons.on('click', '.o_button_generate_leads', function () { + self.do_action({ + name: 'Generate Leads', + type: 'ir.actions.act_window', + res_model: 'crm.iap.lead.mining.request', + target: 'new', + views: [[false, 'form']], + context: {'is_modal': true, 'default_lead_type': lead_type}, + }); + }); + } + } + + var LeadMiningRequestListController = ListController.extend({ + willStart: function() { + var self = this; + var ready = this.getSession().user_has_group('sales_team.group_sale_manager') + .then(function (is_sale_manager) { + if (is_sale_manager) { + self.buttons_template = 'LeadMiningRequestListView.buttons'; + } + }); + return Promise.all([this._super.apply(this, arguments), ready]); + }, + renderButtons: function () { + this._super.apply(this, arguments); + renderGenerateLeadsButton.apply(this, arguments); + } + }); + + var LeadMiningRequestListView = ListView.extend({ + config: _.extend({}, ListView.prototype.config, { + Controller: LeadMiningRequestListController, + }), + }); + + var LeadMiningRequestKanbanController = KanbanController.extend({ + willStart: function() { + var self = this; + var ready = this.getSession().user_has_group('sales_team.group_sale_manager') + .then(function (is_sale_manager) { + if (is_sale_manager) { + self.buttons_template = 'LeadMiningRequestKanbanView.buttons'; + } + }); + return Promise.all([this._super.apply(this, arguments), ready]); + }, + renderButtons: function () { + this._super.apply(this, arguments); + renderGenerateLeadsButton.apply(this, arguments); + } + }); + + var LeadMiningRequestKanbanView = KanbanView.extend({ + config: _.extend({}, KanbanView.prototype.config, { + Controller: LeadMiningRequestKanbanController, + }), + }); + + viewRegistry.add('crm_iap_lead_mining_request_tree', LeadMiningRequestListView); + viewRegistry.add('crm_iap_lead_mining_request_kanban', LeadMiningRequestKanbanView); +}); 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 00000000..577b6cd1 --- /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 <b>Won</b> 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 ?<br>Try the <b>Lead Generation</b> 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/static/src/xml/leads_tree_generate_leads_views.xml b/addons/crm_iap_lead/static/src/xml/leads_tree_generate_leads_views.xml new file mode 100644 index 00000000..8254fb7f --- /dev/null +++ b/addons/crm_iap_lead/static/src/xml/leads_tree_generate_leads_views.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<templates> + <t t-name="LeadMiningRequest.generate_leads_button"> + <button type="button" class="btn btn-secondary o_button_generate_leads"> + Generate Leads + </button> + </t> + + <t t-extend="ListView.buttons" t-name="LeadMiningRequestListView.buttons"> + <t t-jquery="button.o_list_button_add" t-operation="after"> + <t t-call="LeadMiningRequest.generate_leads_button"/> + </t> + </t> + + <t t-extend="KanbanView.buttons" t-name="LeadMiningRequestKanbanView.buttons"> + <t t-jquery="button" t-operation="after"> + <t t-call="LeadMiningRequest.generate_leads_button"/> + </t> + </t> +</templates> |
