Browse Source

Merge pull request #214 from Ommo73/10.0-mail_to_channels_add

10.0 mail to channels add
pull/230/head
Eugene Molotov 5 years ago
committed by GitHub
parent
commit
ad8ea0f1df
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mail_to/__init__.py
  2. 7
      mail_to/__manifest__.py
  3. 8
      mail_to/doc/changelog.rst
  4. 2
      mail_to/models/__init__.py
  5. 18
      mail_to/models/mail_message.py
  6. 26
      mail_to/static/src/js/mail_to.js
  7. 20
      mail_to/static/src/js/test_mail_to.js
  8. 23
      mail_to/static/src/xml/recipient.xml
  9. 5
      mail_to/templates.xml
  10. 3
      mail_to/tests/__init__.py
  11. 21
      mail_to/tests/test_default.py

2
mail_to/__init__.py

@ -1 +1,3 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import models

7
mail_to/__manifest__.py

@ -1,10 +1,15 @@
# -*- coding: utf-8 -*-
# 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""",
"summary": """Allows you be sure, that all discussion participants were notified""",
"category": "Discuss",
"images": ['images/1.png'],
"version": "1.0.1",
"version": "10.0.1.1.0",
"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@it-projects.info",

8
mail_to/doc/changelog.rst

@ -1,7 +1,13 @@
`1.1.0`
-------
- **New**: channels are displayed in recipients
`1.0.1`
-------
- **FIX:** The problem with duplicating the names of recipients was solved.
- **FIX**: the problem with duplicating the names of recipients was solved.
`1.0.0`
-------

2
mail_to/models/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import mail_message

18
mail_to/models/mail_message.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from odoo import models, api
class MailMessage(models.Model):
_inherit = 'mail.message'
@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

26
mail_to/static/src/js/mail_to.js

@ -1,3 +1,8 @@
/* 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/>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). */
odoo.define('mail_to.MailTo', function (require) {
"use strict";
@ -7,23 +12,26 @@ odoo.define('mail_to.MailTo', function (require) {
make_message: function(data){
var msg = this._super(data);
msg.partner_ids = data.partner_ids;
if (!msg.partner_ids) {
msg.channel_names = data.channel_names;
msg.recipients = data.partner_ids.concat(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.partner_ids.length; i++){
if (i >= msg.more_recipients_value){
// append names
more_recipients += msg.partner_ids[i][1];
// separate them with semicolon
if (i < msg.partner_ids.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;
}

20
mail_to/static/src/js/test_mail_to.js

@ -0,0 +1,20 @@
/* 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 email = 'mail_private test email';
var steps = [{
trigger: 'a.recipient_link:first',
content: _t("Open Partners Form From Recipient Link"),
position: 'bottom',
timeout: 70000,
}];
tour.register('mail_to_tour', { test: true, url: '/web' }, steps);
});

23
mail_to/static/src/xml/recipient.xml

@ -1,19 +1,36 @@
<?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>
<t t-extend="mail.ChatThread.Message">
<t t-jquery="p[class=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>
<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.partner_ids.length &gt; message.more_recipients_value">
<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.partner_ids.length - message.more_recipients_value"/> more
and <t t-esc="message.recipients.length - message.more_recipients_value"/> more
</span>
</t>
</t></span>

5
mail_to/templates.xml

@ -1,4 +1,8 @@
<?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>
<data>
<template id="mail_to_assets_backend"
@ -7,6 +11,7 @@
<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>
</xpath>
</template>
</data>

3
mail_to/tests/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import test_default

21
mail_to/tests/test_default.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
import odoo.tests
from odoo.api import Environment
@odoo.tests.common.at_install(True)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_to(self):
cr = self.registry.cursor()
env = Environment(cr, self.uid, {})
env['ir.module.module'].search([('name', '=', 'mail_to')], limit=1).state = 'installed'
cr.release()
self.phantom_js("/web",
"odoo.__DEBUG__.services['web_tour.tour'].run('mail_to_tour', 1000)",
"odoo.__DEBUG__.services['web_tour.tour'].tours.mail_to_tour.ready",
login="admin", timeout=200)
Loading…
Cancel
Save