diff --git a/mail_quoted_reply/README.rst b/mail_quoted_reply/README.rst new file mode 100644 index 0000000..b9b5b64 --- /dev/null +++ b/mail_quoted_reply/README.rst @@ -0,0 +1,80 @@ +================== +Mail Message Reply +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/12.0/mail_message_reply + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_message_reply + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon allow to reply on messages from odoo directly. +It is useful when replying to a message from a customer. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +On the messages from threads, a reply button is shown. +Once it has been pressed, a composer with the reply is shown. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Creu Blanca + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_quoted_reply/__init__.py b/mail_quoted_reply/__init__.py new file mode 100644 index 0000000..aee8895 --- /dev/null +++ b/mail_quoted_reply/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/mail_quoted_reply/__manifest__.py b/mail_quoted_reply/__manifest__.py new file mode 100644 index 0000000..c7ae279 --- /dev/null +++ b/mail_quoted_reply/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2021 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Mail Message Reply', + 'summary': """ + Make a reply using a message""", + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Creu Blanca,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/social', + 'depends': [ + 'mail' + ], + 'qweb': [ + 'static/src/xml/mail_message_reply.xml', + ], + 'data': [ + "templates/assets.xml", + "data/reply_template.xml", + ], +} diff --git a/mail_quoted_reply/data/reply_template.xml b/mail_quoted_reply/data/reply_template.xml new file mode 100644 index 0000000..a8668d5 --- /dev/null +++ b/mail_quoted_reply/data/reply_template.xml @@ -0,0 +1,20 @@ + + + + Reply + Re: ${object.subject} + + + + +
+
+ From: ${object.email_from}
+ Date: ${object.date}
+ Subject: ${object.subject}
+ ${object.body | safe} +
+ ]]>
+
+
diff --git a/mail_quoted_reply/models/__init__.py b/mail_quoted_reply/models/__init__.py new file mode 100644 index 0000000..a2bc21b --- /dev/null +++ b/mail_quoted_reply/models/__init__.py @@ -0,0 +1 @@ +from . import mail_message diff --git a/mail_quoted_reply/models/mail_message.py b/mail_quoted_reply/models/mail_message.py new file mode 100644 index 0000000..b5a1047 --- /dev/null +++ b/mail_quoted_reply/models/mail_message.py @@ -0,0 +1,31 @@ +# Copyright 2021 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class MailMessage(models.Model): + + _inherit = 'mail.message' + + def reply_message(self): + action = self.env.ref( + "mail.action_email_compose_message_wizard" + ).read()[0] + action['context'] = { + "default_model": self._name, + "default_res_id": self.id, + "default_template_id": self.env.ref( + "mail_quoted_reply.reply_template" + ).id, + "default_composition_mode": "comment", + "default_is_log": False, + "is_log": False, + "default_notify": True, + "force_email": True, + "reassign_to_parent": True, + "default_partner_ids": [ + (6, 0, self.partner_ids.ids) + ] + } + return action diff --git a/mail_quoted_reply/readme/CONTRIBUTORS.rst b/mail_quoted_reply/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..8500476 --- /dev/null +++ b/mail_quoted_reply/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Enric Tobella diff --git a/mail_quoted_reply/readme/DESCRIPTION.rst b/mail_quoted_reply/readme/DESCRIPTION.rst new file mode 100644 index 0000000..fbaa89b --- /dev/null +++ b/mail_quoted_reply/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This addon allow to reply on messages from odoo directly. +It is useful when replying to a message from a customer. diff --git a/mail_quoted_reply/readme/USAGE.rst b/mail_quoted_reply/readme/USAGE.rst new file mode 100644 index 0000000..2a57635 --- /dev/null +++ b/mail_quoted_reply/readme/USAGE.rst @@ -0,0 +1,2 @@ +On the messages from threads, a reply button is shown. +Once it has been pressed, a composer with the reply is shown. diff --git a/mail_quoted_reply/static/description/icon.png b/mail_quoted_reply/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/mail_quoted_reply/static/description/icon.png differ diff --git a/mail_quoted_reply/static/src/js/mail_message_reply.js b/mail_quoted_reply/static/src/js/mail_message_reply.js new file mode 100644 index 0000000..6e7c0f6 --- /dev/null +++ b/mail_quoted_reply/static/src/js/mail_message_reply.js @@ -0,0 +1,53 @@ +/* Copyright 2021 Creu Blanca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + */ + odoo.define('mail_quote_reply.reply', function (require) { + "use strict"; + + var ThreadWidget = require('mail.widget.Thread'); + var ThreadField = require('mail.ThreadField'); + var DocumentThread = require('mail.model.DocumentThread'); + + DocumentThread.include({ + _fetchMessages: function(options) { + if (options && options.forceReloadMessages) { + this._mustFetchMessageIDs = true; + } + return this._super.apply(this, arguments) + } + }); + + ThreadField.include({ + start: function () { + var self = this; + return this._super.apply(this, arguments).then(function () { + self._threadWidget.on('reload_thread_messages', self, self._onReloadThreadMessages); + }) + }, + _onReloadThreadMessages: function () { + this._fetchAndRenderThread({forceReloadMessages: true }); + }, + }); + + ThreadWidget.include({ + events: _.defaults({ + "click .o_thread_mail_message_reply": "_onClickMailMessageReply", + }, ThreadWidget.prototype.events), + + _onClickMailMessageReply: function(event) { + var self = this, + msg_id = $(event.currentTarget).data('message-id'); + this._rpc({ + model: "mail.message", + method: "reply_message", + args: [msg_id], + }).then(function (result) { + self.do_action(result, { + on_close: function () { + self.trigger('reload_thread_messages'); + }, + }); + }); + }, + }); +}); diff --git a/mail_quoted_reply/static/src/xml/mail_message_reply.xml b/mail_quoted_reply/static/src/xml/mail_message_reply.xml new file mode 100644 index 0000000..fe3de0d --- /dev/null +++ b/mail_quoted_reply/static/src/xml/mail_message_reply.xml @@ -0,0 +1,12 @@ + + + diff --git a/mail_quoted_reply/templates/assets.xml b/mail_quoted_reply/templates/assets.xml new file mode 100644 index 0000000..261ca0b --- /dev/null +++ b/mail_quoted_reply/templates/assets.xml @@ -0,0 +1,17 @@ + + + + + + +