Browse Source

🌈 mail_to: pre-commit auto cleanup

Signed-off-by: Vildan Safin <safin@it-projects.info>
pull/299/head
Vildan Safin 4 years ago
parent
commit
9610732f11
  1. 3
      mail_to/__manifest__.py
  2. 23
      mail_to/models/mail_message.py
  3. 18
      mail_to/static/src/js/mail_to.js
  4. 44
      mail_to/static/src/js/test_mail_to.js
  5. 42
      mail_to/static/src/xml/recipient.xml
  6. 10
      mail_to/templates.xml
  7. 3
      mail_to/tests/test_default.py

3
mail_to/__manifest__.py

@ -7,9 +7,8 @@
"name": """Show message recipients""", "name": """Show message recipients""",
"summary": """Allows you be sure, that all discussion participants were notified""", "summary": """Allows you be sure, that all discussion participants were notified""",
"category": "Discuss", "category": "Discuss",
"images": ['images/1.png'],
"images": ["images/1.png"],
"version": "12.0.1.1.0", "version": "12.0.1.1.0",
"author": "IT-Projects LLC, Pavel Romanchenko", "author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@itpp.dev", "support": "apps@itpp.dev",
"website": "https://it-projects.info", "website": "https://it-projects.info",

23
mail_to/models/mail_message.py

@ -1,30 +1,33 @@
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/> # Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# Copyright 2019 Eugene Molotov <https://it-projects.info/team/em230418> # Copyright 2019 Eugene Molotov <https://it-projects.info/team/em230418>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from odoo import models, api
from odoo import api, models
class MailMessage(models.Model): class MailMessage(models.Model):
_inherit = 'mail.message'
_inherit = "mail.message"
# взято с mail_base # взято с mail_base
@api.multi @api.multi
def write(self, values): def write(self, values):
if values.get('needaction_partner_ids'):
if not values.get('partner_ids'):
values['partner_ids'] = []
for triplet in values.get('needaction_partner_ids'):
if values.get("needaction_partner_ids"):
if not values.get("partner_ids"):
values["partner_ids"] = []
for triplet in values.get("needaction_partner_ids"):
if triplet[0] == 6: if triplet[0] == 6:
for i in triplet[2]: for i in triplet[2]:
values['partner_ids'].append((4, i, False))
values["partner_ids"].append((4, i, False))
return super(MailMessage, self).write(values) return super(MailMessage, self).write(values)
@api.multi @api.multi
def message_format(self): def message_format(self):
messages_values = super(MailMessage, self).message_format() messages_values = super(MailMessage, self).message_format()
for i in messages_values: for i in messages_values:
if i['channel_ids']:
i['channel_names'] = self.env['mail.channel'].browse(i['channel_ids']).mapped(
lambda r: [r.id, '#' + r.display_name])
if i["channel_ids"]:
i["channel_names"] = (
self.env["mail.channel"]
.browse(i["channel_ids"])
.mapped(lambda r: [r.id, "#" + r.display_name])
)
return messages_values return messages_values

18
mail_to/static/src/js/mail_to.js

@ -4,7 +4,7 @@
* Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/> * Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
* Copyright 2019-2020 Eugene Molotov <https://it-projects.info/team/em230418> * Copyright 2019-2020 Eugene Molotov <https://it-projects.info/team/em230418>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). */ * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). */
odoo.define('mail_to.MailTo', function (require) {
odoo.define("mail_to.MailTo", function(require) {
"use strict"; "use strict";
var MailManager = require("mail.Manager"); var MailManager = require("mail.Manager");
@ -15,28 +15,30 @@ odoo.define('mail_to.MailTo', function (require) {
msg.partner_ids = data.partner_ids; msg.partner_ids = data.partner_ids;
msg.channel_names = data.channel_names; msg.channel_names = data.channel_names;
msg.channel_ids = data.channel_ids; msg.channel_ids = data.channel_ids;
msg.recipients = data.partner_ids.concat(data.channel_names ? data.channel_names : []);
msg.recipients = data.partner_ids.concat(
data.channel_names ? data.channel_names : []
);
if (!msg.partner_ids && !msg.channel_names) { if (!msg.partner_ids && !msg.channel_names) {
return msg; return msg;
} }
var more_recipients = '';
// value which define more recipients
var more_recipients = "";
// Value which define more recipients
msg.more_recipients_value = 4; msg.more_recipients_value = 4;
for (var i = 0; i < msg.recipients.length; i++) { for (var i = 0; i < msg.recipients.length; i++) {
if (i >= msg.more_recipients_value) { if (i >= msg.more_recipients_value) {
// append names
// Append names
more_recipients += msg.recipients[i][1]; more_recipients += msg.recipients[i][1];
// separate them with semicolon
// Separate them with semicolon
if (i < msg.recipients.length - 1) { if (i < msg.recipients.length - 1) {
more_recipients += '; ';
more_recipients += "; ";
} }
} }
} }
msg.more_recipients = more_recipients; msg.more_recipients = more_recipients;
return msg; return msg;
}
},
}); });
return MailManager; return MailManager;

44
mail_to/static/src/js/test_mail_to.js

@ -1,34 +1,42 @@
/* Copyright 2018 Artem Rafailov <https://it-projects.info/team/KolushovAlexandr> /* Copyright 2018 Artem Rafailov <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).*/ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).*/
odoo.define('mail_to.tour', function (require) {
odoo.define("mail_to.tour", function(require) {
"use strict"; "use strict";
var tour = require("web_tour.tour"); var tour = require("web_tour.tour");
var core = require('web.core');
var core = require("web.core");
var _t = core._t; var _t = core._t;
var steps = [tour.STEPS.SHOW_APPS_MENU_ITEM, {
var steps = [
tour.STEPS.SHOW_APPS_MENU_ITEM,
{
trigger: '.o_app[data-menu-xmlid="mail.menu_root_discuss"]', trigger: '.o_app[data-menu-xmlid="mail.menu_root_discuss"]',
content: _t('Want to <b>get in touch</b> with your contacts? <i>Discuss with them here.</i>'),
position: 'right',
edition: 'community',
},{
content: _t(
"Want to <b>get in touch</b> with your contacts? <i>Discuss with them here.</i>"
),
position: "right",
edition: "community",
},
{
trigger: '.fa.fa-plus.o_add[data-type="public"]', trigger: '.fa.fa-plus.o_add[data-type="public"]',
position: 'right',
edition: 'community',
position: "right",
edition: "community",
run: function(actions) { run: function(actions) {
$('.o_input.ui-autocomplete-input').val("Channel #" + String(new Date().getTime()));
$('.o_input.ui-autocomplete-input').keydown();
$(".o_input.ui-autocomplete-input").val(
"Channel #" + String(new Date().getTime())
);
$(".o_input.ui-autocomplete-input").keydown();
setTimeout(function() { setTimeout(function() {
$('.ui-menu-item > a').click();
$(".ui-menu-item > a").click();
}, 1000); }, 1000);
}, },
},{
trigger: 'a.recipient_link:first',
},
{
trigger: "a.recipient_link:first",
content: _t("Open Partners Form From Recipient Link"), content: _t("Open Partners Form From Recipient Link"),
position: 'bottom',
}];
tour.register('mail_to_tour', { test: true, url: '/web' }, steps);
position: "bottom",
},
];
tour.register("mail_to_tour", {test: true, url: "/web"}, steps);
}); });

42
mail_to/static/src/xml/recipient.xml

@ -6,33 +6,53 @@
<template> <template>
<t t-extend="mail.widget.Thread.Message"> <t t-extend="mail.widget.Thread.Message">
<t t-jquery="p.o_mail_info span:last" t-operation="after"> <t t-jquery="p.o_mail_info span:last" t-operation="after">
<span class="recipients_info"><t t-if="message.partner_ids">
<span class="recipients_info">
<t t-if="message.partner_ids">
<t t-if="message.partner_ids.length > 0">To: </t> <t t-if="message.partner_ids.length > 0">To: </t>
<t t-else="message.channel_ids.length > 0">To: </t> <t t-else="message.channel_ids.length > 0">To: </t>
<t t-foreach="message.partner_ids.length" t-as="i"> <t t-foreach="message.partner_ids.length" t-as="i">
<t t-if="i &lt; message.more_recipients_value"> <t t-if="i &lt; message.more_recipients_value">
<a t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=res.partner', message.partner_ids[i][0])" class="recipient_link">
<i t-esc="message.partner_ids[i][1]"/><t t-if="i &lt; message.partner_ids.length - 1">; </t><t t-else="message.channel_ids.length > 0 and message.partner_ids.length &lt; 4">; </t>
<a
t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=res.partner', message.partner_ids[i][0])"
class="recipient_link"
>
<i t-esc="message.partner_ids[i][1]" />
<t t-if="i &lt; message.partner_ids.length - 1">; </t>
<t
t-else="message.channel_ids.length > 0 and message.partner_ids.length &lt; 4"
>; </t>
</a> </a>
</t> </t>
</t> </t>
<t t-if="message.channel_names"> <t t-if="message.channel_names">
<t t-foreach="message.channel_ids.length" t-as="i"> <t t-foreach="message.channel_ids.length" t-as="i">
<t t-if="message.partner_ids.length &lt; message.more_recipients_value and (message.partner_ids.length + i) &lt; message.more_recipients_value">
<a t-if="message.channel_names[i]" t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=mail.channel', message.channel_names[i][0])" class="recipient_link">
<i t-esc="message.channel_names[i][1]"/><t t-if="i &lt; message.channel_ids.length - 1">; </t>
<t
t-if="message.partner_ids.length &lt; message.more_recipients_value and (message.partner_ids.length + i) &lt; message.more_recipients_value"
>
<a
t-if="message.channel_names[i]"
t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=mail.channel', message.channel_names[i][0])"
class="recipient_link"
>
<i t-esc="message.channel_names[i][1]" />
<t
t-if="i &lt; message.channel_ids.length - 1"
>; </t>
</a> </a>
</t> </t>
</t> </t>
</t> </t>
<t t-if="message.recipients.length &gt; message.more_recipients_value">
<t
t-if="message.recipients.length &gt; message.more_recipients_value"
>
<span t-att-title="message.more_recipients"> <span t-att-title="message.more_recipients">
and <t t-esc="message.recipients.length - message.more_recipients_value"/> more
and <t
t-esc="message.recipients.length - message.more_recipients_value"
/> more
</span> </span>
</t> </t>
</t></span>
</t>
</span>
</t> </t>
</t> </t>
</template> </template>

10
mail_to/templates.xml

@ -12,8 +12,14 @@
> >
<xpath expr="." position="inside"> <xpath expr="." position="inside">
<link rel="stylesheet" href="/mail_to/static/src/css/mail_to.css" /> <link rel="stylesheet" href="/mail_to/static/src/css/mail_to.css" />
<script src="/mail_to/static/src/js/mail_to.js" type="text/javascript"></script>
<script src="/mail_to/static/src/js/test_mail_to.js" type="text/javascript"></script>
<script
src="/mail_to/static/src/js/mail_to.js"
type="text/javascript"
/>
<script
src="/mail_to/static/src/js/test_mail_to.js"
type="text/javascript"
/>
</xpath> </xpath>
</template> </template>
</data> </data>

3
mail_to/tests/test_default.py

@ -2,9 +2,10 @@
# Copyright 2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev> # Copyright 2018 Artyom Losev <https://it-projects.info/team/ArtyomLosev>
# Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr> # Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
import odoo.tests
from werkzeug import url_encode from werkzeug import url_encode
import odoo.tests
@odoo.tests.common.at_install(True) @odoo.tests.common.at_install(True)
@odoo.tests.common.post_install(True) @odoo.tests.common.post_install(True)

Loading…
Cancel
Save