[ADD] mail_quoted_reply
This commit is contained in:
parent
a3018b1a16
commit
45329a2c29
80
mail_quoted_reply/README.rst
Normal file
80
mail_quoted_reply/README.rst
Normal file
@ -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 <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20mail_message_reply%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
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 <https://github.com/OCA/social/tree/12.0/mail_message_reply>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
2
mail_quoted_reply/__init__.py
Normal file
2
mail_quoted_reply/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from . import wizards
|
22
mail_quoted_reply/__manifest__.py
Normal file
22
mail_quoted_reply/__manifest__.py
Normal file
@ -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",
|
||||
],
|
||||
}
|
20
mail_quoted_reply/data/reply_template.xml
Normal file
20
mail_quoted_reply/data/reply_template.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="reply_template" model="mail.template">
|
||||
<field name="name">Reply</field>
|
||||
<field name="subject">Re: ${object.subject}</field>
|
||||
<field name="use_default_to" eval="True"/>
|
||||
<field name="model_id" ref="mail.model_mail_message"/>
|
||||
<field name="body_html"><![CDATA[
|
||||
<div>
|
||||
</div>
|
||||
<br/>
|
||||
<blockquote style="padding-right:0px; padding-left:5px; border-left-color: #000; margin-left:5px; margin-right:0px;border-left-width: 2px; border-left-style:solid">
|
||||
From: ${object.email_from}<br/>
|
||||
Date: ${object.date}<br/>
|
||||
Subject: ${object.subject}<br/>
|
||||
${object.body | safe}
|
||||
</blockquote>
|
||||
]]></field>
|
||||
</record>
|
||||
</odoo>
|
1
mail_quoted_reply/models/__init__.py
Normal file
1
mail_quoted_reply/models/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import mail_message
|
31
mail_quoted_reply/models/mail_message.py
Normal file
31
mail_quoted_reply/models/mail_message.py
Normal file
@ -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
|
1
mail_quoted_reply/readme/CONTRIBUTORS.rst
Normal file
1
mail_quoted_reply/readme/CONTRIBUTORS.rst
Normal file
@ -0,0 +1 @@
|
||||
* Enric Tobella
|
2
mail_quoted_reply/readme/DESCRIPTION.rst
Normal file
2
mail_quoted_reply/readme/DESCRIPTION.rst
Normal file
@ -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.
|
2
mail_quoted_reply/readme/USAGE.rst
Normal file
2
mail_quoted_reply/readme/USAGE.rst
Normal file
@ -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.
|
BIN
mail_quoted_reply/static/description/icon.png
Normal file
BIN
mail_quoted_reply/static/description/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
53
mail_quoted_reply/static/src/js/mail_message_reply.js
Normal file
53
mail_quoted_reply/static/src/js/mail_message_reply.js
Normal file
@ -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');
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
12
mail_quoted_reply/static/src/xml/mail_message_reply.xml
Normal file
12
mail_quoted_reply/static/src/xml/mail_message_reply.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright 2021 Creu Blanca
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
<template>
|
||||
<t t-extend="mail.widget.Thread.Message">
|
||||
<t t-jquery=".o_thread_message_reply" t-operation="after">
|
||||
<i t-if="message.isLinkedToDocumentThread() and !options.displayReplyIcons and !message.isSystemNotification()"
|
||||
class="fa fa-reply o_thread_icon o_thread_mail_message_reply"
|
||||
t-att-data-message-id="message.getID()" title="Reply" role="img" aria-label="Reply"/>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
17
mail_quoted_reply/templates/assets.xml
Normal file
17
mail_quoted_reply/templates/assets.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Copyright 2014-2015 Grupo ESOC <http://www.grupoesoc.es>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<template id="assets_backend"
|
||||
name="mail_quoted_reply assets"
|
||||
inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
|
||||
<script type="text/javascript"
|
||||
src="/mail_quoted_reply/static/src/js/mail_message_reply.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
1
mail_quoted_reply/tests/__init__.py
Normal file
1
mail_quoted_reply/tests/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import test_reply
|
38
mail_quoted_reply/tests/test_reply.py
Normal file
38
mail_quoted_reply/tests/test_reply.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Copyright 2021 Creu Blanca
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.tests import TransactionCase
|
||||
|
||||
|
||||
class TestMessageReply(TransactionCase):
|
||||
def test_reply(self):
|
||||
partner = self.env["res.partner"].create({
|
||||
"name": "demo partner"
|
||||
})
|
||||
self.assertFalse(
|
||||
partner.message_ids.filtered(
|
||||
lambda r: r.message_type != 'notification'
|
||||
)
|
||||
)
|
||||
message = partner.message_post(
|
||||
body="demo message",
|
||||
message_type="email"
|
||||
)
|
||||
partner.refresh()
|
||||
self.assertIn(
|
||||
message,
|
||||
partner.message_ids.filtered(
|
||||
lambda r: r.message_type != 'notification')
|
||||
)
|
||||
self.assertFalse(partner.message_ids.filtered(
|
||||
lambda r: r.message_type != 'notification' and r != message
|
||||
))
|
||||
action = message.reply_message()
|
||||
wizard = self.env[action["res_model"]].with_context(
|
||||
action["context"]
|
||||
).create({})
|
||||
wizard.action_send_mail()
|
||||
new_message = partner.message_ids.filtered(
|
||||
lambda r: r.message_type != 'notification' and r != message
|
||||
)
|
||||
self.assertTrue(new_message)
|
||||
self.assertEqual(1, len(new_message))
|
1
mail_quoted_reply/wizards/__init__.py
Normal file
1
mail_quoted_reply/wizards/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import mail_compose_message_reply
|
19
mail_quoted_reply/wizards/mail_compose_message_reply.py
Normal file
19
mail_quoted_reply/wizards/mail_compose_message_reply.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2021 Creu Blanca
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class MailComposeMessageReply(models.TransientModel):
|
||||
|
||||
_inherit = "mail.compose.message"
|
||||
|
||||
def send_mail(self, auto_commit=False):
|
||||
if self.env.context.get("reassign_to_parent"):
|
||||
for record in self:
|
||||
if record.model == "mail.message":
|
||||
parent = self.env[record.model].browse(record.res_id)
|
||||
record.model = parent.model
|
||||
record.res_id = parent.res_id
|
||||
record.parent_id = parent
|
||||
return super().send_mail(auto_commit=auto_commit)
|
Loading…
x
Reference in New Issue
Block a user