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. 28
      mail_to/static/src/js/mail_to.js
  4. 56
      mail_to/static/src/js/test_mail_to.js
  5. 66
      mail_to/static/src/xml/recipient.xml
  6. 14
      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""",
"summary": """Allows you be sure, that all discussion participants were notified""",
"category": "Discuss",
"images": ['images/1.png'],
"images": ["images/1.png"],
"version": "12.0.1.1.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@itpp.dev",
"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 Eugene Molotov <https://it-projects.info/team/em230418>
# 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):
_inherit = 'mail.message'
_inherit = "mail.message"
# взято с mail_base
@api.multi
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:
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)
@api.multi
def message_format(self):
messages_values = super(MailMessage, self).message_format()
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

28
mail_to/static/src/js/mail_to.js

@ -4,7 +4,7 @@
* Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
* Copyright 2019-2020 Eugene Molotov <https://it-projects.info/team/em230418>
* 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";
var MailManager = require("mail.Manager");
@ -15,28 +15,30 @@ odoo.define('mail_to.MailTo', function (require) {
msg.partner_ids = data.partner_ids;
msg.channel_names = data.channel_names;
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) {
return msg;
}
var more_recipients = '';
// value which define more recipients
var more_recipients = "";
// Value which define more recipients
msg.more_recipients_value = 4;
for (var i = 0; i < msg.recipients.length; i++){
if (i >= msg.more_recipients_value){
// append names
more_recipients += msg.recipients[i][1];
// separate them with semicolon
if (i < msg.recipients.length - 1){
more_recipients += '; ';
}
for (var i = 0; i < msg.recipients.length; i++) {
if (i >= msg.more_recipients_value) {
// Append names
more_recipients += msg.recipients[i][1];
// Separate them with semicolon
if (i < msg.recipients.length - 1) {
more_recipients += "; ";
}
}
}
msg.more_recipients = more_recipients;
return msg;
}
},
});
return MailManager;

56
mail_to/static/src/js/test_mail_to.js

@ -1,34 +1,42 @@
/* Copyright 2018 Artem Rafailov <https://it-projects.info/team/KolushovAlexandr>
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";
var tour = require("web_tour.tour");
var core = require('web.core');
var core = require("web.core");
var _t = core._t;
var steps = [tour.STEPS.SHOW_APPS_MENU_ITEM, {
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',
},{
trigger: '.fa.fa-plus.o_add[data-type="public"]',
position: 'right',
edition: 'community',
run: function (actions) {
$('.o_input.ui-autocomplete-input').val("Channel #" + String(new Date().getTime()));
$('.o_input.ui-autocomplete-input').keydown();
setTimeout(function(){
$('.ui-menu-item > a').click();
}, 1000);
var steps = [
tour.STEPS.SHOW_APPS_MENU_ITEM,
{
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",
},
},{
trigger: 'a.recipient_link:first',
content: _t("Open Partners Form From Recipient Link"),
position: 'bottom',
}];
tour.register('mail_to_tour', { test: true, url: '/web' }, steps);
{
trigger: '.fa.fa-plus.o_add[data-type="public"]',
position: "right",
edition: "community",
run: function(actions) {
$(".o_input.ui-autocomplete-input").val(
"Channel #" + String(new Date().getTime())
);
$(".o_input.ui-autocomplete-input").keydown();
setTimeout(function() {
$(".ui-menu-item > a").click();
}, 1000);
},
},
{
trigger: "a.recipient_link:first",
content: _t("Open Partners Form From Recipient Link"),
position: "bottom",
},
];
tour.register("mail_to_tour", {test: true, url: "/web"}, steps);
});

66
mail_to/static/src/xml/recipient.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--Copyright 2016 x620 <https://github.com/x620>
Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
@ -6,33 +6,53 @@
<template>
<t t-extend="mail.widget.Thread.Message">
<t t-jquery="p.o_mail_info span:last" t-operation="after">
<span class="recipients_info"><t t-if="message.partner_ids">
<t t-if="message.partner_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-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>
</t>
<t t-if="message.channel_names">
<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>
<span class="recipients_info">
<t t-if="message.partner_ids">
<t t-if="message.partner_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-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>
</t>
</t>
<t t-if="message.recipients.length &gt; message.more_recipients_value">
<span t-att-title="message.more_recipients">
and <t t-esc="message.recipients.length - message.more_recipients_value"/> more
<t t-if="message.channel_names">
<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>
</a>
</t>
</t>
</t>
<t
t-if="message.recipients.length &gt; message.more_recipients_value"
>
<span t-att-title="message.more_recipients">
and <t
t-esc="message.recipients.length - message.more_recipients_value"
/> more
</span>
</t>
</t>
</t></span>
</span>
</t>
</t>
</template>

14
mail_to/templates.xml

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!--Copyright 2016 x620 <https://github.com/x620>
Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
@ -11,9 +11,15 @@
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<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>
<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
src="/mail_to/static/src/js/test_mail_to.js"
type="text/javascript"
/>
</xpath>
</template>
</data>

3
mail_to/tests/test_default.py

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

Loading…
Cancel
Save