Browse Source

Merge pull request #299 from Enigma228322/12.0-mail_to

commit is created by 👷‍♂️ Merge Bot: https://odoo-devops.readthedocs.io/en/latest/git/github-merge-bot.html
pull/301/head
Mitchell Admin 4 years ago
committed by GitHub
parent
commit
97b03c9b04
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mail_to/__init__.py
  2. 9
      mail_to/__manifest__.py
  3. 6
      mail_to/doc/changelog.rst
  4. 3
      mail_to/i18n/de.po
  5. 19
      mail_to/i18n/mail_to.pot
  6. 8
      mail_to/i18n/sl.po
  7. 1
      mail_to/models/__init__.py
  8. 33
      mail_to/models/mail_message.py
  9. 45
      mail_to/static/src/js/mail_to.js
  10. 42
      mail_to/static/src/js/test_mail_to.js
  11. 53
      mail_to/static/src/xml/recipient.xml
  12. 12
      mail_to/templates.xml
  13. 1
      mail_to/tests/__init__.py
  14. 13
      mail_to/tests/test_default.py

2
mail_to/__init__.py

@ -0,0 +1,2 @@
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import models

9
mail_to/__manifest__.py

@ -1,13 +1,18 @@
# Copyright 2016 x620 <https://github.com/x620>
# Copyright 2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Ruslan Ronzhin
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
{ {
"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.0.1",
"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",
"license": "Other OSI approved licence", # MIT
"license": "LGPL-3",
"price": 40.00, "price": 40.00,
"currency": "EUR", "currency": "EUR",
"depends": ["mail"], "depends": ["mail"],

6
mail_to/doc/changelog.rst

@ -1,3 +1,9 @@
`1.1.0`
-------
- **New**: Channels are displayed in recipients
`1.0.1` `1.0.1`
------- -------

3
mail_to/i18n/de.po

@ -13,7 +13,8 @@ msgstr ""
"POT-Creation-Date: 2018-05-05 23:09+0000\n" "POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n" "PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Ermin Trevisan <trevi@twanda.com>, 2019\n" "Last-Translator: Ermin Trevisan <trevi@twanda.com>, 2019\n"
"Language-Team: German (https://www.transifex.com/it-projects-llc/teams/76080/de/)\n"
"Language-Team: German (https://www.transifex.com/it-projects-llc/teams/76080/"
"de/)\n"
"Language: de\n" "Language: de\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"

19
mail_to/i18n/mail_to.pot

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
@ -13,23 +13,36 @@ msgstr ""
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: mail_to
#: model:ir.model,name:mail_to.model_mail_message
msgid "Message"
msgstr ""
#. module: mail_to
#. openerp-web
#: code:addons/mail_to/static/src/js/test_mail_to.js:13
#, python-format
msgid "Open Partners Form From Recipient Link"
msgstr ""
#. module: mail_to #. module: mail_to
#. openerp-web #. openerp-web
#: code:addons/mail_to/static/src/xml/recipient.xml:10 #: code:addons/mail_to/static/src/xml/recipient.xml:10
#: code:addons/mail_to/static/src/xml/recipient.xml:11
#, python-format #, python-format
msgid "To:" msgid "To:"
msgstr "" msgstr ""
#. module: mail_to #. module: mail_to
#. openerp-web #. openerp-web
#: code:addons/mail_to/static/src/xml/recipient.xml:24
#: code:addons/mail_to/static/src/xml/recipient.xml:32
#, python-format #, python-format
msgid "and" msgid "and"
msgstr "" msgstr ""
#. module: mail_to #. module: mail_to
#. openerp-web #. openerp-web
#: code:addons/mail_to/static/src/xml/recipient.xml:25
#: code:addons/mail_to/static/src/xml/recipient.xml:33
#, python-format #, python-format
msgid "more" msgid "more"
msgstr "" msgstr ""

8
mail_to/i18n/sl.po

@ -12,12 +12,14 @@ msgstr ""
"POT-Creation-Date: 2018-05-05 23:09+0000\n" "POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n" "PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Matjaz Mozetic <m.mozetic@matmoz.si>, 2019\n" "Last-Translator: Matjaz Mozetic <m.mozetic@matmoz.si>, 2019\n"
"Language-Team: Slovenian (https://www.transifex.com/it-projects-llc/teams/76080/sl/)\n"
"Language-Team: Slovenian (https://www.transifex.com/it-projects-llc/"
"teams/76080/sl/)\n"
"Language: sl\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
"%100==4 ? 2 : 3);\n"
#. module: mail_to #. module: mail_to
#. openerp-web #. openerp-web

1
mail_to/models/__init__.py

@ -0,0 +1 @@
from . import mail_message

33
mail_to/models/mail_message.py

@ -0,0 +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 api, models
class MailMessage(models.Model):
_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 triplet[0] == 6:
for i in triplet[2]:
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])
)
return messages_values

45
mail_to/static/src/js/mail_to.js

@ -0,0 +1,45 @@
/* Copyright 2016 x620 <https://github.com/x620>
* Copyright 2016-2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
* Copyright 2017 Artyom Losev <https://it-projects.info/>
* 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) {
"use strict";
var MailManager = require("mail.Manager");
MailManager.include({
_makeMessage: function(data) {
var msg = this._super(data);
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 : []
);
if (!msg.partner_ids && !msg.channel_names) {
return msg;
}
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 += "; ";
}
}
}
msg.more_recipients = more_recipients;
return msg;
},
});
return MailManager;
});

42
mail_to/static/src/js/test_mail_to.js

@ -0,0 +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) {
"use strict";
var tour = require("web_tour.tour");
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);
},
},
{
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);
});

53
mail_to/static/src/xml/recipient.xml

@ -1,25 +1,54 @@
<?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/>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<template> <template>
<t t-extend="mail.widget.Thread.Message"> <t t-extend="mail.widget.Thread.Message">
<t t-jquery="p.o_mail_info" t-operation="append">
<t t-jquery="p.o_mail_info span:last" t-operation="after">
<span class="recipients_info"> <span class="recipients_info">
<t t-set="partner_ids" t-value="message.getCustomerEmailData()" />
<t t-if="partner_ids">
<t t-if="partner_ids.length > 0">To: </t>
<t t-foreach="partner_ids.length" t-as="i">
<t t-if="i &lt; 4">
<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 <a
t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=res.partner', partner_ids[i][0])"
t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=res.partner', message.partner_ids[i][0])"
class="recipient_link" class="recipient_link"
> >
<i t-esc="partner_ids[i][1]" />
<t t-if="i &lt; partner_ids.length - 1">; </t>
<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="partner_ids.length &gt; 4">
<span t-att-title="more_recipients">
and <t t-esc="partner_ids.length - 4" /> 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> </span>
</t> </t>
</t> </t>

12
mail_to/templates.xml

@ -1,4 +1,8 @@
<?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/>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<openerp> <openerp>
<data> <data>
<template <template
@ -8,6 +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
src="/mail_to/static/src/js/test_mail_to.js"
type="text/javascript"
/>
</xpath> </xpath>
</template> </template>
</data> </data>

1
mail_to/tests/__init__.py

@ -1 +1,2 @@
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import test_default from . import test_default

13
mail_to/tests/test_default.py

@ -1,3 +1,7 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# 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).
from werkzeug import url_encode from werkzeug import url_encode
import odoo.tests import odoo.tests
@ -38,16 +42,11 @@ class TestUi(odoo.tests.HttpCase):
env["mail.notification"].create( env["mail.notification"].create(
{"res_partner_id": p, "mail_message_id": msg.id, "is_read": False} {"res_partner_id": p, "mail_message_id": msg.id, "is_read": False}
) )
code = """
setTimeout(function () {
console.log($('a.recipient_link').length && 'ok' || 'error');
}, 3000);
"""
link = "/web#%s" % url_encode({"action": "mail.action_discuss"}) link = "/web#%s" % url_encode({"action": "mail.action_discuss"})
self.phantom_js( self.phantom_js(
link, link,
code,
"odoo.__DEBUG__.services['web_tour.tour'].tours.mail_tour.ready",
"odoo.__DEBUG__.services['web_tour.tour'].run('mail_to_tour', 1000);",
"odoo.__DEBUG__.services['web_tour.tour'].tours.mail_to_tour.ready",
login="admin", login="admin",
) )
Loading…
Cancel
Save