Browse Source
Merge pull request #187 from KolushovAlexandr/12.0-mail_to-port
Merge pull request #187 from KolushovAlexandr/12.0-mail_to-port
⬆️1️⃣2️⃣ mail_topull/194/head
Ramil
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 62 deletions
-
8mail_to/README.rst
-
6mail_to/__manifest__.py
-
4mail_to/static/description/index.html
-
30mail_to/static/src/js/mail_to.js
-
30mail_to/static/src/xml/recipient.xml
-
1mail_to/templates.xml
-
42mail_to/tests/test_default.py
@ -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; |
|||
}); |
@ -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 < message.more_recipients_value"> |
|||
<a t-att-href="_.str.sprintf('/web?#id=%s&view_type=form&model=res.partner', message.partner_ids[i][0])" class="recipient_link"> |
|||
<i t-esc="message.partner_ids[i][1]"/><t t-if="i < 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 < 4"> |
|||
<a t-att-href="_.str.sprintf('/web?#id=%s&view_type=form&model=res.partner', partner_ids[i][0])" class="recipient_link"> |
|||
<i t-esc="partner_ids[i][1]"/><t t-if="i < partner_ids.length - 1">; </t> |
|||
</a> |
|||
</t> |
|||
</t> |
|||
<t t-if="message.partner_ids.length > 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 > 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,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") |
Write
Preview
Loading…
Cancel
Save
Reference in new issue