Browse Source
Merge remote-tracking branch 'Eugene/12.0-mail_addons-merge-mail_to-fix' into 12.0-mail_to
Merge remote-tracking branch 'Eugene/12.0-mail_addons-merge-mail_to-fix' into 12.0-mail_to
Signed-off-by: Vildan Safin <safin@it-projects.info>pull/299/head
Vildan Safin
4 years ago
14 changed files with 180 additions and 35 deletions
-
2mail_to/__init__.py
-
10mail_to/__manifest__.py
-
6mail_to/doc/changelog.rst
-
3mail_to/i18n/de.po
-
19mail_to/i18n/mail_to.pot
-
8mail_to/i18n/sl.po
-
1mail_to/models/__init__.py
-
29mail_to/models/mail_message.py
-
42mail_to/static/src/js/mail_to.js
-
20mail_to/static/src/js/test_mail_to.js
-
46mail_to/static/src/xml/recipient.xml
-
5mail_to/templates.xml
-
1mail_to/tests/__init__.py
-
7mail_to/tests/test_default.py
@ -0,0 +1,2 @@ |
|||||
|
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). |
||||
|
from . import models |
@ -0,0 +1 @@ |
|||||
|
from . import mail_message |
@ -0,0 +1,29 @@ |
|||||
|
# 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' |
||||
|
|
||||
|
# взято с mail_base |
||||
|
@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() |
||||
|
for i in messages_values: |
||||
|
if i['channel_ids']: |
||||
|
i['channel_names'] = self.env['mail.channel'].browse(i['channel_ids']).mapped( |
||||
|
lambda r: [r.id, '#' + r.display_name]) |
||||
|
|
||||
|
return messages_values |
@ -0,0 +1,42 @@ |
|||||
|
/* 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"; |
||||
|
|
||||
|
var MailManager = require("mail.Manager"); |
||||
|
MailManager.include({ |
||||
|
_makeMessage: function(data) { |
||||
|
var msg = this._super(data); |
||||
|
|
||||
|
msg.partner_ids = data.partner_ids; |
||||
|
msg.channel_names = data.channel_names; |
||||
|
msg.channel_ids = data.channel_ids; |
||||
|
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.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; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
return MailManager; |
||||
|
}); |
@ -0,0 +1,20 @@ |
|||||
|
/* Copyright 2018 Artem Rafailov <https://it-projects.info/team/KolushovAlexandr> |
||||
|
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).*/
|
||||
|
odoo.define('mail_to.tour', function (require) { |
||||
|
"use strict"; |
||||
|
|
||||
|
var tour = require("web_tour.tour"); |
||||
|
var core = require('web.core'); |
||||
|
var _t = core._t; |
||||
|
|
||||
|
var email = 'mail_private test email'; |
||||
|
var steps = [{ |
||||
|
trigger: 'a.recipient_link:first', |
||||
|
content: _t("Open Partners Form From Recipient Link"), |
||||
|
position: 'bottom', |
||||
|
timeout: 70000, |
||||
|
}]; |
||||
|
|
||||
|
tour.register('mail_to_tour', { test: true, url: '/web' }, steps); |
||||
|
|
||||
|
}); |
@ -1,29 +1,43 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
<?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> |
<template> |
||||
<t t-extend="mail.widget.Thread.Message"> |
<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> |
|
||||
|
<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-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-else="message.channel_ids.length > 0 and message.partner_ids.length < 4">; </t> |
||||
</a> |
</a> |
||||
</t> |
</t> |
||||
</t> |
|
||||
<t t-if="partner_ids.length > 4"> |
|
||||
|
<t t-if="message.partner_ids.length > 4"> |
||||
<span t-att-title="more_recipients"> |
<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> |
</span> |
||||
</t> |
</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 < message.more_recipients_value and (message.partner_ids.length + i) < message.more_recipients_value"> |
||||
|
<a t-if="message.channel_names[i]" t-att-href="_.str.sprintf('/web?#id=%s&view_type=form&model=mail.channel', message.channel_names[i][0])" class="recipient_link"> |
||||
|
<i t-esc="message.channel_names[i][1]"/><t t-if="i < message.channel_ids.length - 1">; </t> |
||||
|
</a> |
||||
|
</t> |
||||
|
</t> |
||||
|
</t> |
||||
|
|
||||
|
|
||||
|
<t t-if="message.recipients.length > message.more_recipients_value"> |
||||
|
<span t-att-title="message.more_recipients"> |
||||
|
and <t t-esc="message.recipients.length - message.more_recipients_value"/> more |
||||
</span> |
</span> |
||||
</t> |
</t> |
||||
|
</t></span> |
||||
|
</t> |
||||
</t> |
</t> |
||||
</template> |
</template> |
@ -1 +1,2 @@ |
|||||
|
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). |
||||
from . import test_default |
from . import test_default |
Write
Preview
Loading…
Cancel
Save
Reference in new issue