Skip to content

Commit

Permalink
🚑 mail_to: fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ommo73 committed Dec 26, 2019
1 parent ae52da7 commit 1d415a2
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 140 deletions.
2 changes: 1 addition & 1 deletion mail_to/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import models
from . import models
3 changes: 1 addition & 2 deletions mail_to/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
`1.1.0`
-------

- **New**: Channels are displayed in recipients

- **New**: channels are displayed in recipients

`1.0.1`
-------
Expand Down
7 changes: 1 addition & 6 deletions mail_to/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@
# Translators:
# Dawid Runowski <[email protected]>, 2019
# Ermin Trevisan <[email protected]>, 2019
#
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Ermin Trevisan <[email protected]>, 2019\n"
<<<<<<< HEAD
"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"
>>>>>>> upstream/11.0
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
66 changes: 0 additions & 66 deletions mail_to/i18n/mail_to.pot

This file was deleted.

12 changes: 5 additions & 7 deletions mail_to/i18n/sl.po
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mail_to
#
#
# Translators:
# Matjaz Mozetic <[email protected]>, 2019
#
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 23:09+0000\n"
"PO-Revision-Date: 2018-04-21 00:05+0000\n"
"Last-Translator: Matjaz Mozetic <[email protected]>, 2019\n"
"Language-Team: Slovenian (https://www.transifex.com/it-projects-llc/"
"teams/76080/sl/)\n"
"Language: sl\n"
"Language-Team: Slovenian (https://www.transifex.com/it-projects-llc/teams/76080/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
"%100==4 ? 2 : 3);\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"

#. module: mail_to
#. openerp-web
Expand Down
11 changes: 11 additions & 0 deletions mail_to/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,16 @@ def message_format(self):
if i['channel_ids']:
i['channel_names'] = self.env['mail.channel'].browse(i['channel_ids']).mapped(
lambda r: [r.id, '#' + r.display_name])
else:
i['channel_names'] = []

partner_ids = set(i['needaction_partner_ids'])
partner_ids.update(set(map(lambda x: x[0], i['partner_ids'])))
partner_ids.update(set(map(lambda x: x[0], i['customer_email_data'])))
if partner_ids:
i['partner_names'] = self.env['res.partner'].browse(partner_ids).mapped(
lambda r: [r.id, r.name])
else:
i['partner_names'] = []

return messages_values
23 changes: 13 additions & 10 deletions mail_to/static/src/js/mail_to.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
odoo.define('mail_to.MailTo', function (require) {
"use strict";

var chat_manager = require('mail_base.base').chat_manager;
var MailManager = require("mail.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;
MailManager.include({
_makeMessage: function(data) {
var msg = this._super(data);
msg.partner_names = data.partner_names;
msg.channel_names = data.channel_names;
msg.recipients = data.partner_ids.concat(data.channel_names);
if (!msg.partner_ids && !msg.channel_names) {
msg.recipients = msg.partner_names.concat(msg.channel_names);

if (!msg.partner_names && !msg.channel_names) {
return msg;
}

Expand All @@ -27,14 +28,16 @@ chat_manager.make_message = function (data) {
more_recipients += msg.recipients[i][1];
// separate them with semicolon
if (i < msg.recipients.length - 1){
more_recipients += '; ';
more_recipients += ', ';
}
}
}

msg.more_recipients = more_recipients;

return msg;
};
}
});

return chat_manager;
return MailManager;
});
20 changes: 0 additions & 20 deletions mail_to/static/src/js/test_mail_to.js

This file was deleted.

51 changes: 24 additions & 27 deletions mail_to/static/src/xml/recipient.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,37 @@
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<template>
<t t-extend="mail.widget.Thread.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><t t-else="message.channel_ids.length > 0 and message.partner_ids.length &lt; 4">; </t>
</a>
</t>
<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-jquery="p.o_mail_info" t-operation="append">
<span class="recipients_info">
<t t-if="message.partner_names or message.channel_names">
<t t-if="message.partner_names.length > 0">To: </t>
<t t-else="message.channel_names.length > 0">To: </t>
<t t-foreach="message.partner_names.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_names[i][0])" class="recipient_link">
<i t-esc="message.partner_names[i][1]"/><t t-if="i &lt; message.partner_names.length - 1">, </t><t t-else="message.channel_names.length > 0 and message.partner_names.length &lt; 4">; </t>
</a>
</t>
</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>
</a>
<t t-if="message.channel_names">
<t t-foreach="message.channel_names.length" t-as="i">
<t t-if="message.partner_names.length &lt; message.more_recipients_value and (message.partner_names.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_names.length - 1">, </t>
</a>
</t>
</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-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>
3 changes: 2 additions & 1 deletion mail_to/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
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/mail_to.js" type="text/javascript"/>
</xpath>
</template>
</data>
</openerp>

0 comments on commit 1d415a2

Please sign in to comment.