Skip to content

Commit

Permalink
⚡ mail_to New: channels are displayed in recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
Ommo73 committed Jul 29, 2019
1 parent 7cb04f8 commit c09bf28
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 14 deletions.
1 change: 1 addition & 0 deletions mail_to/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
4 changes: 3 additions & 1 deletion mail_to/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-
# 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.1",

"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "[email protected]",
Expand Down
8 changes: 7 additions & 1 deletion mail_to/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -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`
-------
Expand Down
2 changes: 2 additions & 0 deletions mail_to/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import mail_message
20 changes: 20 additions & 0 deletions mail_to/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- 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):
message_values = super(MailMessage, self).message_format()
for i in message_values:
if i['channel_ids']:
i['channel_names'] = []
for channel_id in i['channel_ids']:
channel = self.env['mail.channel'].search([('id', '=', channel_id)])
i['channel_names'].append([channel_id, '#' + channel['display_name']])

return message_values
26 changes: 17 additions & 9 deletions mail_to/static/src/js/mail_to.js
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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;
}
Expand Down
23 changes: 20 additions & 3 deletions mail_to/static/src/xml/recipient.xml
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
3 changes: 3 additions & 0 deletions mail_to/templates.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0"?>
<!--Copyright 2016 x620 <https://github.com/x620>
Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<openerp>
<data>
<template id="mail_to_assets_backend"
Expand Down

0 comments on commit c09bf28

Please sign in to comment.