diff options
| author | Jérémy Hennecart <jeh@odoo.com> | 2020-07-06 15:42:35 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-08-17 06:42:28 +0000 |
| commit | a895cfcded2c50aa4992a8cb98ee6e9c2780d64c (patch) | |
| tree | 3a3a69064f32891b9cac49e06da8d7e9322ea643 /addons/crm/static/src/js/crm_form.js | |
| parent | decfd753f968cbea8b2955562b7774e88ac7d637 (diff) | |
[IMP] crm: harmonize won triggers with rainbowman
PURPOSE
Make sure the Rainbowman animation is rightly triggered whichever way the user
marks the opportunity as won. Especially relevant for the onboarding as we want
to show the first rainbowman to users completing the tour.
SPECIFICATIONS
Now the rainbowman and its finely-tuned message are displayed to the user when
he uses the statusbar, mark lead as won using action buttons or drag and drop
a lead in the won stage in kanban view.
LINKS
Task ID-2287758
PR #54553
Diffstat (limited to 'addons/crm/static/src/js/crm_form.js')
| -rw-r--r-- | addons/crm/static/src/js/crm_form.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/addons/crm/static/src/js/crm_form.js b/addons/crm/static/src/js/crm_form.js new file mode 100644 index 00000000000..b8f026e618f --- /dev/null +++ b/addons/crm/static/src/js/crm_form.js @@ -0,0 +1,53 @@ +odoo.define("crm.crm_form", function (require) { + "use strict"; + + /** + * This From Controller makes sure we display a rainbowman message + * when the stage is won, even when we click on the statusbar. + * When the stage of a lead is changed and data are saved, we check + * if the lead is won and if a message should be displayed to the user + * with a rainbowman like when the user click on the button "Mark Won". + */ + + var FormController = require('web.FormController'); + var FormView = require('web.FormView'); + var viewRegistry = require('web.view_registry'); + + var CrmFormController = FormController.extend({ + /** + * After data are saved we display a possible rainbowman + * message when the stage is won. + * @override + */ + _applyChanges: async function (dataPointID, changes, event) { + var result = await this._super(...arguments); + if ('stage_id' in changes) { + const message = await this._rpc({ + model: 'crm.lead', + method : 'get_rainbowman_message', + args: [[parseInt(event.target.res_id)]], + }); + if (message) { + this.trigger_up('show_effect', { + message: message, + type: 'rainbow_man', + }); + } + } + return result; + }, + }); + + var CrmFormView = FormView.extend({ + config: _.extend({}, FormView.prototype.config, { + Controller: CrmFormController, + }), + }); + + viewRegistry.add('crm_form', CrmFormView); + + return { + CrmFormController: CrmFormController, + CrmFormView: CrmFormView, + }; +}); |
