diff options
| author | Thibault Delavallée <tde@odoo.com> | 2019-06-27 16:44:04 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-07-12 14:54:11 +0000 |
| commit | 14ccc770bba873f591a0a556d2c28e36ccc78d1e (patch) | |
| tree | b3518860b5eb3346e0d8b81066a1cbc0e8d12af5 /addons/sms/static/src/js/fields_phone_widget.js | |
| parent | 9ad7a88a08ceccc3665acd8972ac47614205bf0e (diff) | |
[IMP] sms: improve SMS widget
Related to task 1922163
Linked to PR #33510
Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
Diffstat (limited to 'addons/sms/static/src/js/fields_phone_widget.js')
| -rw-r--r-- | addons/sms/static/src/js/fields_phone_widget.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/addons/sms/static/src/js/fields_phone_widget.js b/addons/sms/static/src/js/fields_phone_widget.js new file mode 100644 index 00000000000..f02d9b8625a --- /dev/null +++ b/addons/sms/static/src/js/fields_phone_widget.js @@ -0,0 +1,70 @@ +odoo.define('sms.fields', function (require) { +"use strict"; + +var basic_fields = require('web.basic_fields'); +var core = require('web.core'); +var session = require('web.session'); + +var _t = core._t; + +/** + * Override of FieldPhone to use add a button calling SMS composer if option activated + */ + +var Phone = basic_fields.FieldPhone; +Phone.include({ + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * Open SMS composer wizard + * + * @private + */ + _onClickSMS: function (ev) { + ev.preventDefault(); + + var context = session.user_context; + context = _.extend({}, context, { + default_res_model: this.model, + default_res_id: parseInt(this.res_id), + default_number_field_name: this.name, + default_composition_mode: 'comment', + }); + + return this.do_action({ + title: _t('Send SMS Text Message'), + type: 'ir.actions.act_window', + res_model: 'sms.composer', + target: 'new', + views: [[false, 'form']], + context: context, + }); + }, + + /** + * Add a button to call the composer wizard + * + * @override + * @private + */ + _renderReadonly: function () { + var def = this._super.apply(this, arguments); + if (this.nodeOptions.enable_sms) { + var $composerButton = $('<a>', { + title: _t('Send SMS Text Message'), + href: '', + class: 'btn-sm btn-link mb4 fa fa-comment o_field_phone_sms', + }); + $composerButton.on('click', this._onClickSMS.bind(this)); + this.$el = $('<div/>').append(this.$el).append($composerButton); + } + + return def; + }, +}); + +return Phone; + +}); |
