From 32ba6a0d987005d6fc15a7de7f4786e5167fe291 Mon Sep 17 00:00:00 2001 From: ommo73 Date: Thu, 18 Jul 2019 16:58:48 +0500 Subject: [PATCH] :zap: mail_to New: channels are displayed in recipients --- mail_to/__init__.py | 2 ++ mail_to/__manifest__.py | 7 ++++++- mail_to/doc/changelog.rst | 8 +++++++- mail_to/models/__init__.py | 2 ++ mail_to/models/mail_message.py | 18 ++++++++++++++++++ mail_to/static/src/js/mail_to.js | 26 +++++++++++++++++--------- mail_to/static/src/js/test_mail_to.js | 20 ++++++++++++++++++++ mail_to/static/src/xml/recipient.xml | 23 ++++++++++++++++++++--- mail_to/templates.xml | 5 +++++ mail_to/tests/__init__.py | 3 +++ mail_to/tests/test_default.py | 21 +++++++++++++++++++++ 11 files changed, 121 insertions(+), 14 deletions(-) create mode 100644 mail_to/models/__init__.py create mode 100644 mail_to/models/mail_message.py create mode 100644 mail_to/static/src/js/test_mail_to.js create mode 100644 mail_to/tests/__init__.py create mode 100644 mail_to/tests/test_default.py diff --git a/mail_to/__init__.py b/mail_to/__init__.py index 40a96af..c786efe 100644 --- a/mail_to/__init__.py +++ b/mail_to/__init__.py @@ -1 +1,3 @@ # -*- coding: utf-8 -*- +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). +from . import models diff --git a/mail_to/__manifest__.py b/mail_to/__manifest__.py index 5767214..a256126 100644 --- a/mail_to/__manifest__.py +++ b/mail_to/__manifest__.py @@ -1,10 +1,15 @@ # -*- coding: utf-8 -*- +# Copyright 2016 x620 +# Copyright 2016 Ivan Yelizariev +# Copyright 2018 Ruslan Ronzhin +# Copyright 2019 Artem Rafailov +# 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.0", "author": "IT-Projects LLC, Pavel Romanchenko", "support": "apps@it-projects.info", diff --git a/mail_to/doc/changelog.rst b/mail_to/doc/changelog.rst index ea27aff..c376831 100644 --- a/mail_to/doc/changelog.rst +++ b/mail_to/doc/changelog.rst @@ -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` ------- diff --git a/mail_to/models/__init__.py b/mail_to/models/__init__.py new file mode 100644 index 0000000..5327e73 --- /dev/null +++ b/mail_to/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import mail_message diff --git a/mail_to/models/mail_message.py b/mail_to/models/mail_message.py new file mode 100644 index 0000000..049915a --- /dev/null +++ b/mail_to/models/mail_message.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Artem Rafailov +# 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): + 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 diff --git a/mail_to/static/src/js/mail_to.js b/mail_to/static/src/js/mail_to.js index bb24815..2b425dc 100644 --- a/mail_to/static/src/js/mail_to.js +++ b/mail_to/static/src/js/mail_to.js @@ -1,3 +1,8 @@ +/* Copyright 2016 x620 + * Copyright 2016-2017 Ivan Yelizariev + * Copyright 2017 Artyom Losev + * Copyright 2019 Artem Rafailov + * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). */ odoo.define('mail_to.MailTo', function (require) { "use strict"; @@ -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; } diff --git a/mail_to/static/src/js/test_mail_to.js b/mail_to/static/src/js/test_mail_to.js new file mode 100644 index 0000000..ff20b9d --- /dev/null +++ b/mail_to/static/src/js/test_mail_to.js @@ -0,0 +1,20 @@ +/* Copyright 2018 Artem Rafailov + 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); + +}); diff --git a/mail_to/static/src/xml/recipient.xml b/mail_to/static/src/xml/recipient.xml index 3b5a50f..ede8ece 100644 --- a/mail_to/static/src/xml/recipient.xml +++ b/mail_to/static/src/xml/recipient.xml @@ -1,19 +1,36 @@ +