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 18, 2019
1 parent ae52da7 commit e67caee
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
11 changes: 11 additions & 0 deletions mail_to/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
class MailMessage(models.Model):
_inherit = 'mail.message'

@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()
Expand Down
13 changes: 7 additions & 6 deletions mail_to/static/src/js/mail_to.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
odoo.define('mail_to.MailTo', function (require) {
"use strict";

var chat_manager = require('mail_base.base').chat_manager;
var MailManager = require("mail.Manager");
MailManager.include({
_makeMessage: function(data) {
var msg = this._super(data);

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;
msg.channel_names = data.channel_names;
msg.recipients = data.partner_ids.concat(data.channel_names);
Expand All @@ -34,7 +34,8 @@ chat_manager.make_message = function (data) {

msg.more_recipients = more_recipients;
return msg;
};
}
});

return chat_manager;
return MailManager;
});
14 changes: 7 additions & 7 deletions mail_to/static/src/xml/recipient.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
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">
<t t-jquery="p.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-else="message.channel_names.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>
<i t-esc="message.partner_ids[i][1]"/><t t-if="i &lt; message.partner_ids.length - 1">; </t><t t-else="message.channel_names.length > 0 and message.partner_ids.length &lt; 4">; </t>
</a>
</t>
<t t-if="partner_ids.length &gt; 4">
<t t-if="message.partner_ids.length &gt; 4">
<span t-att-title="more_recipients">
and <t t-esc="partner_ids.length - 4"/> more
and <t t-esc="message.partner_ids.length - 4"/> more
</span>
</t>

</t>
<t t-if="message.channel_names">
<t t-foreach="message.channel_ids.length" t-as="i">
<t t-foreach="message.channel_names.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>
<i t-esc="message.channel_names[i][1]"/><t t-if="i &lt; message.channel_names.length - 1">; </t>
</a>
</t>
</t>
Expand Down
1 change: 1 addition & 0 deletions mail_to/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,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>
</xpath>
</template>
</data>
</openerp>

0 comments on commit e67caee

Please sign in to comment.