Browse Source

⬆️1️⃣2️⃣ mail_to

pull/187/head
KolushovAlexandr 6 years ago
parent
commit
54a65c86e5
No known key found for this signature in database GPG Key ID: C3E04B793421FD2
  1. 8
      mail_to/README.rst
  2. 6
      mail_to/__manifest__.py
  3. 4
      mail_to/static/description/index.html
  4. 30
      mail_to/static/src/js/mail_to.js
  5. 30
      mail_to/static/src/xml/recipient.xml
  6. 1
      mail_to/templates.xml
  7. 42
      mail_to/tests/test_default.py

8
mail_to/README.rst

@ -19,7 +19,7 @@ Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/mail_to/>`__.
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/mail_to/>`__.
Thank you for understanding!
@ -28,12 +28,12 @@ Maintainers
Further information
===================
Demo: http://runbot.it-projects.info/demo/mail-addons/11.0
Demo: http://runbot.it-projects.info/demo/mail-addons/12.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_to/
HTML Description: https://apps.odoo.com/apps/modules/12.0/mail_to/
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_
Tested on Odoo 11.0 ecbf7aa4714479229658d14cce28fa00376ed390
Tested on Odoo 12.0 3c40d732bf03c8b656ab170319425f02fddfb2f4

6
mail_to/__manifest__.py

@ -3,7 +3,7 @@
"summary": """Allows you be sure, that all discussion participants were notified""",
"category": "Discuss",
"images": ['images/1.png'],
"version": "11.0.1.0.1",
"version": "12.0.1.0.1",
"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "apps@it-projects.info",
@ -13,7 +13,7 @@
"currency": "EUR",
"depends": [
'mail_base',
'mail',
],
"external_dependencies": {"python": [], "bin": []},
"data": [
@ -23,6 +23,6 @@
'static/src/xml/recipient.xml',
],
"demo": [],
"installable": False,
"installable": True,
"auto_install": False,
}

4
mail_to/static/description/index.html

@ -41,7 +41,7 @@
-o-transform: rotate(5deg);
-moz-transform: rotate(5deg);
-ms-transform: rotate(5deg);">
Tested on Odoo<br/>10.0 community
Tested on Odoo<br/>12.0 community
</div>
<div style="margin-top: 15px;
position: relative;
@ -58,7 +58,7 @@
-o-transform: rotate(3deg);
-moz-transform: rotate(3deg);
-ms-transform: rotate(3deg);">
Tested on Odoo<br/>10.0 enterprise
Tested on Odoo<br/>12.0 enterprise
</div>
</div>
</div>

30
mail_to/static/src/js/mail_to.js

@ -1,30 +0,0 @@
odoo.define('mail_to.MailTo', function (require) {
"use strict";
var chat_manager = require('mail_base.base').chat_manager;
var make_message_super = chat_manager.make_message;
chat_manager.make_message = function (data) {
var msg = make_message_super.call(this, data);
msg.partner_ids = data.partner_ids;
if (!msg.partner_ids) {
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 += '; ';
}
}
}
msg.more_recipients = more_recipients;
return msg;
};
return chat_manager;
});

30
mail_to/static/src/xml/recipient.xml

@ -1,22 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<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-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-extend="mail.widget.Thread.Message">
<t t-jquery="p.o_mail_info" t-operation="append">
<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">
<a t-att-href="_.str.sprintf('/web?#id=%s&amp;view_type=form&amp;model=res.partner', partner_ids[i][0])" class="recipient_link">
<i t-esc="partner_ids[i][1]"/><t t-if="i &lt; partner_ids.length - 1">; </t>
</a>
</t>
</t>
<t t-if="message.partner_ids.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
<t t-if="partner_ids.length &gt; 4">
<span t-att-title="more_recipients">
and <t t-esc="partner_ids.length - 4"/> more
</span>
</t>
</t></span>
</t>
</span>
</t>
</t>
</template>

1
mail_to/templates.xml

@ -6,7 +6,6 @@
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>
</xpath>
</template>
</data>

42
mail_to/tests/test_default.py

@ -1,18 +1,46 @@
import odoo.tests
from werkzeug import url_encode
@odoo.tests.common.at_install(False)
@odoo.tests.common.at_install(True)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_01_mail_to(self):
# checks the presence of an element with a link to the recipient
# TODO: instead of timeout, try to put $('a.recipient_link') as ready argument of phantom_js (third parameter)
env = self.env
# needed because tests are run before the module is marked as
# installed. In js web will only load qweb coming from modules
# that are returned by the backend in module_boot. Without
# this you end up with js, css but no qweb.
env['ir.module.module'].search([('name', '=', 'mail_to')], limit=1).state = 'installed'
# Handle messages in Odoo
res_users_ids = env['res.users'].search([])
res_users_ids.write({'notification_type': 'inbox'})
# demo messages
partner_ids = env['res.partner'].search([])
msg = env['mail.message'].create({
'subject': '_Test',
'body': self._testMethodName,
'subtype_id': self.ref('mail.mt_comment'),
'model': 'mail.channel',
'partner_ids': [(6, 0, [i.id for i in partner_ids])],
})
# notifications for everyone
for p in partner_ids.ids:
env['mail.notification'].create({
'res_partner_id': p,
'mail_message_id': msg.id,
'is_read': False,
})
code = """
setTimeout(function () {
$('a.recipient_link')[0].click();
console.log('ok');
}, 1000);
console.log($('a.recipient_link').length && 'ok' || 'error');
}, 3000);
"""
link = '/web#action=%s' % self.ref('mail.mail_channel_action_client_chat')
self.phantom_js(link, code, "odoo.__DEBUG__.services['mail_to.MailTo']", login="admin")
link = '/web#%s' % url_encode({'action': 'mail.action_discuss'})
self.phantom_js(link, code, "odoo.__DEBUG__.services['web_tour.tour'].tours.mail_tour.ready", login="admin")
Loading…
Cancel
Save