diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index 332fe34..2ab4d8c 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -786,14 +786,22 @@ chat_manager.post_message = function (data, options) { subtype_id: data.subtype_id }); - var model = new Model(options.model); - return model.call('message_post', [options.res_id], msg).then(function (msg_id) { - return MessageModel.call('message_format', [msg_id]).then(function (msgs) { - msgs[0].model = options.model; - msgs[0].res_id = options.res_id; - chat_manager.mail_tools.add_message(msgs[0]); + if (options.model && options.res_id){ + var model = new Model(options.model); + return model.call('message_post', [options.res_id], msg).then(function (msg_id) { + return MessageModel.call('message_format', [msg_id]).then(function (msgs) { + msgs[0].model = options.model; + msgs[0].res_id = options.res_id; + chat_manager.mail_tools.add_message(msgs[0]); + }); }); - }); + } else { + options.model = 'mail.compose.message'; + var compose_model = new Model(options.model); + return compose_model.call('create', [msg, {default_parent_id: options.parent_id}]).then(function(id){ + return compose_model.call('send_mail_action', [id, {}]); + }); + } } }; chat_manager.get_message = function (id) { diff --git a/mail_reply/README.rst b/mail_reply/README.rst new file mode 100644 index 0000000..b31799a --- /dev/null +++ b/mail_reply/README.rst @@ -0,0 +1,16 @@ +========================== + Always show reply button +========================== + +The module allows to reply to any message. Out-of-box odoo shows reply button for messages attached to some record. + +Further information +=================== + +HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_reply/ + +Usage instructions: ``_ + +Changelog: ``_ + +Tested on Odoo 9.0 d3dd4161ad0598ebaa659fbd083457c77aa9448d diff --git a/mail_reply/__init__.py b/mail_reply/__init__.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/mail_reply/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/mail_reply/__openerp__.py b/mail_reply/__openerp__.py new file mode 100644 index 0000000..038abb4 --- /dev/null +++ b/mail_reply/__openerp__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +{ + "name": """Always show reply button""", + "summary": """Got a message out of a Record? Now you can reply to it too!""", + "category": "Discuss", + "images": [], + "version": "1.0.0", + + "author": "IT-Projects LLC, Pavel Romanchenko", + "website": "https://it-projects.info", + "license": "LGPL-3", + "price": 40.00, + "currency": "EUR", + + "depends": [ + "mail_base", + ], + "external_dependencies": {"python": [], "bin": []}, + "data": [ + 'templates.xml' + ], + "qweb": [ + "static/src/xml/reply_button.xml", + ], + "demo": [], + "installable": True, + "auto_install": False, +} diff --git a/mail_reply/doc/changelog.rst b/mail_reply/doc/changelog.rst new file mode 100644 index 0000000..e2b0277 --- /dev/null +++ b/mail_reply/doc/changelog.rst @@ -0,0 +1,7 @@ +Changelog +========= + +`1.0.0` +------- + +- Init version diff --git a/mail_reply/doc/index.rst b/mail_reply/doc/index.rst new file mode 100644 index 0000000..d195d86 --- /dev/null +++ b/mail_reply/doc/index.rst @@ -0,0 +1,9 @@ +=================== + Show reply button +=================== + +Usage +===== + +* Open Discuss menu +* All messages have reply button diff --git a/mail_reply/static/description/icon.png b/mail_reply/static/description/icon.png new file mode 100644 index 0000000..79f7d8f Binary files /dev/null and b/mail_reply/static/description/icon.png differ diff --git a/mail_reply/static/description/inbox.png b/mail_reply/static/description/inbox.png new file mode 100644 index 0000000..1fca806 Binary files /dev/null and b/mail_reply/static/description/inbox.png differ diff --git a/mail_reply/static/description/index.html b/mail_reply/static/description/index.html new file mode 100644 index 0000000..68556b9 --- /dev/null +++ b/mail_reply/static/description/index.html @@ -0,0 +1,29 @@ +
+
+
+

Always show reply button

+

Got a message out of a Record? Now you can reply to it too!

+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+

Need our service?

+

Contact us by email or fill out request form

+ +
+
+
diff --git a/mail_reply/static/src/js/mail_reply.js b/mail_reply/static/src/js/mail_reply.js new file mode 100644 index 0000000..b1a023f --- /dev/null +++ b/mail_reply/static/src/js/mail_reply.js @@ -0,0 +1,46 @@ +odoo.define('mail_reply.reply', function (require) { +"use strict"; + +var core = require('web.core'); +var base_obj = require('mail_base.base'); + +var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); +ChatAction.include({ + select_message: function(message_id) { + this._super.apply(this, arguments); + var message = base_obj.chat_manager.get_message(message_id); + var subject = ''; + if (message.record_name){ + subject = "Re: " + message.record_name; + } else if (message.subject){ + subject = "Re: " + message.subject; + } + this.extended_composer.set_subject(subject); + }, + on_post_message: function(message){ + var self = this; + var options = this.selected_message ? {} : {channel_id: this.channel.id}; + if (this.selected_message) { + message.subtype = 'mail.mt_comment'; + message.subtype_id = false; + message.message_type = 'comment'; + message.content_subtype = 'html'; + + options.model = this.selected_message.model; + options.res_id = this.selected_message.res_id; + options.parent_id = this.selected_message.id; + } + base_obj.chat_manager + .post_message(message, options) + .then(function() { + if (self.selected_message) { + self.render_snackbar('mail.chat.MessageSentSnackbar', {record_name: self.selected_message.record_name}, 5000); + self.unselect_message(); + } else { + self.thread.scroll_to(); + } + }); + } +}); + +}); diff --git a/mail_reply/static/src/xml/reply_button.xml b/mail_reply/static/src/xml/reply_button.xml new file mode 100644 index 0000000..8b7cb2d --- /dev/null +++ b/mail_reply/static/src/xml/reply_button.xml @@ -0,0 +1,10 @@ + + diff --git a/mail_reply/templates.xml b/mail_reply/templates.xml new file mode 100644 index 0000000..f75bd81 --- /dev/null +++ b/mail_reply/templates.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file