[IMP] black, isort, prettier

This commit is contained in:
Lois Rilo 2022-06-03 20:10:54 +02:00 committed by jb
parent 45329a2c29
commit 1919902772
7 changed files with 83 additions and 86 deletions

View File

@ -2,21 +2,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Mail Message Reply',
'summary': """
"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",
],
"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",],
}

View File

@ -3,9 +3,11 @@
<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[
<field name="use_default_to" eval="True" />
<field name="model_id" ref="mail.model_mail_message" />
<field
name="body_html"
><![CDATA[
<div>
</div>
<br/>

View File

@ -6,26 +6,20 @@ from odoo import models
class MailMessage(models.Model):
_inherit = 'mail.message'
_inherit = "mail.message"
def reply_message(self):
action = self.env.ref(
"mail.action_email_compose_message_wizard"
).read()[0]
action['context'] = {
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_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)
]
"default_partner_ids": [(6, 0, self.partner_ids.ids)],
}
return action

View File

@ -1,53 +1,60 @@
/* 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) {
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');
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)
}
return this._super.apply(this, arguments);
},
});
ThreadField.include({
start: function () {
start: function() {
var self = this;
return this._super.apply(this, arguments).then(function () {
self._threadWidget.on('reload_thread_messages', self, self._onReloadThreadMessages);
})
return this._super.apply(this, arguments).then(function() {
self._threadWidget.on(
"reload_thread_messages",
self,
self._onReloadThreadMessages
);
});
},
_onReloadThreadMessages: function () {
this._fetchAndRenderThread({forceReloadMessages: true });
_onReloadThreadMessages: function() {
this._fetchAndRenderThread({forceReloadMessages: true});
},
});
ThreadWidget.include({
events: _.defaults({
"click .o_thread_mail_message_reply": "_onClickMailMessageReply",
}, ThreadWidget.prototype.events),
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');
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');
},
});
model: "mail.message",
method: "reply_message",
args: [msg_id],
}).then(function(result) {
self.do_action(result, {
on_close: function() {
self.trigger("reload_thread_messages");
},
});
});
},
});
});

View File

@ -1,12 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?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"/>
<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>

View File

@ -1,17 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<?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">
<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"/>
<script
type="text/javascript"
src="/mail_quoted_reply/static/src/js/mail_message_reply.js"
/>
</xpath>
</template>
</odoo>

View File

@ -5,34 +5,28 @@ from odoo.tests import TransactionCase
class TestMessageReply(TransactionCase):
def test_reply(self):
partner = self.env["res.partner"].create({
"name": "demo partner"
})
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.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')
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
)
)
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 = (
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
lambda r: r.message_type != "notification" and r != message
)
self.assertTrue(new_message)
self.assertEqual(1, len(new_message))