diff options
Diffstat (limited to 'addons/sms/static/src/models')
| -rw-r--r-- | addons/sms/static/src/models/message/message.js | 33 | ||||
| -rw-r--r-- | addons/sms/static/src/models/notification_group/notification_group.js | 62 |
2 files changed, 95 insertions, 0 deletions
diff --git a/addons/sms/static/src/models/message/message.js b/addons/sms/static/src/models/message/message.js new file mode 100644 index 00000000..2f468cc0 --- /dev/null +++ b/addons/sms/static/src/models/message/message.js @@ -0,0 +1,33 @@ +odoo.define('sms/static/src/models/message/message.js', function (require) { +'use strict'; + +const { + registerInstancePatchModel, +} = require('mail/static/src/model/model_core.js'); + +registerInstancePatchModel('mail.message', 'sms/static/src/models/message/message.js', { + + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + /** + * @override + */ + openResendAction() { + if (this.message_type === 'sms') { + this.env.bus.trigger('do-action', { + action: 'sms.sms_resend_action', + options: { + additional_context: { + default_mail_message_id: this.id, + }, + }, + }); + } else { + this._super(...arguments); + } + }, +}); + +}); diff --git a/addons/sms/static/src/models/notification_group/notification_group.js b/addons/sms/static/src/models/notification_group/notification_group.js new file mode 100644 index 00000000..887d9a7d --- /dev/null +++ b/addons/sms/static/src/models/notification_group/notification_group.js @@ -0,0 +1,62 @@ +odoo.define('sms/static/src/models/notification_group/notification_group.js', function (require) { +'use strict'; + +const { + registerInstancePatchModel, +} = require('mail/static/src/model/model_core.js'); + +registerInstancePatchModel('mail.notification_group', 'sms/static/src/models/notification_group/notification_group.js', { + + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + /** + * @override + */ + openCancelAction() { + if (this.notification_type !== 'sms') { + return this._super(...arguments); + } + this.env.bus.trigger('do-action', { + action: 'sms.sms_cancel_action', + options: { + additional_context: { + default_model: this.res_model, + unread_counter: this.notifications.length, + }, + }, + }); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @override + */ + _openDocuments() { + if (this.notification_type !== 'sms') { + return this._super(...arguments); + } + this.env.bus.trigger('do-action', { + action: { + name: this.env._t("SMS Failures"), + type: 'ir.actions.act_window', + view_mode: 'kanban,list,form', + views: [[false, 'kanban'], [false, 'list'], [false, 'form']], + target: 'current', + res_model: this.res_model, + domain: [['message_has_sms_error', '=', true]], + }, + }); + if (this.env.messaging.device.isMobile) { + // messaging menu has a higher z-index than views so it must + // be closed to ensure the visibility of the view + this.env.messaging.messagingMenu.close(); + } + }, +}); + +}); |
