diff --git a/.travis.yml b/.travis.yml index 67b0503..74b5194 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,8 @@ env: matrix: - LINT_CHECK="1" - CHECK_TAGS="1" - - TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1" + - TESTS="1" ODOO_REPO="odoo/odoo" + - MAKEPOT="1" - TESTS="1" ODOO_REPO="OCA/OCB" install: diff --git a/mail_base/README.rst b/mail_base/README.rst index d93f8c6..2fabe3c 100644 --- a/mail_base/README.rst +++ b/mail_base/README.rst @@ -7,7 +7,7 @@ * fixes toggling left bar * fixes Recipients field. Out-of-box this field could be empty. -One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js `__ +One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js `__ // to do: move this to mail.utils diff --git a/mail_base/__init__.py b/mail_base/__init__.py index 7cdad7f..dd5379d 100644 --- a/mail_base/__init__.py +++ b/mail_base/__init__.py @@ -1,3 +1,4 @@ +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html) from . import models from . import controllers diff --git a/mail_base/__manifest__.py b/mail_base/__manifest__.py index 87e8f3f..12d535e 100644 --- a/mail_base/__manifest__.py +++ b/mail_base/__manifest__.py @@ -1,9 +1,13 @@ +# Copyright 2016 x620 +# Copyright 2018 Ruslan Ronzhin +# Copyright 2016-2019 Ivan Yelizariev +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html) { "name": "Mail Base", "summary": """Makes Mail extendable""", "category": "Discuss", "images": [], - "version": "11.0.1.0.5", + "version": "11.0.1.1.0", "author": "IT-Projects LLC, Pavel Romanchenko", "support": "apps@it-projects.info", diff --git a/mail_base/controllers/main.py b/mail_base/controllers/main.py index fa772e8..d739b56 100644 --- a/mail_base/controllers/main.py +++ b/mail_base/controllers/main.py @@ -1,3 +1,6 @@ +# Copyright 2017 mikaelh +# Copyright 2017-2019 Ivan Yelizariev +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html) from openerp.http import request from openerp.addons.bus.controllers.main import BusController diff --git a/mail_base/doc/changelog.rst b/mail_base/doc/changelog.rst index d1474d8..8825558 100644 --- a/mail_base/doc/changelog.rst +++ b/mail_base/doc/changelog.rst @@ -1,3 +1,7 @@ +`1.1.0` +------- +- **New**: added ability to select channels for private message sending. + `1.0.5` ------- **FIX**: polling errors on heavy server load diff --git a/mail_base/models.py b/mail_base/models.py index 9bdf491..5f0a329 100644 --- a/mail_base/models.py +++ b/mail_base/models.py @@ -1,3 +1,6 @@ +# Copyright 2016 x620 +# Copyright 2017 Ivan Yelizariev +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html) from openerp import api, models @@ -12,8 +15,8 @@ class MailMessage(models.Model): values['partner_ids'] = [] for triplet in values.get('needaction_partner_ids'): if triplet[0] == 6: - for id in triplet[2]: - values['partner_ids'].append((4, id, False)) + for i in triplet[2]: + values['partner_ids'].append((4, i, False)) return super(MailMessage, self).write(values) diff --git a/mail_base/static/lib/base.js b/mail_base/static/lib/base.js index 42433e7..a00f7bc 100644 --- a/mail_base/static/lib/base.js +++ b/mail_base/static/lib/base.js @@ -1,3 +1,6 @@ +/* Copyright 2017 Artyom Losev + Copyright 2019 Artem Rafailov + License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). */ odoo.define('mail_base.base', function (require) { "use strict"; diff --git a/mail_multi_website/README.rst b/mail_multi_website/README.rst index a7c4dd1..862852d 100644 --- a/mail_multi_website/README.rst +++ b/mail_multi_website/README.rst @@ -2,9 +2,9 @@ :target: https://www.gnu.org/licenses/lgpl :alt: License: LGPL-3 -=========================================== - Email Addresses and Templates per Website -=========================================== +===================== + Multi-Brand Mailing +===================== Mail-related stuff for multi-website support diff --git a/mail_multi_website/__manifest__.py b/mail_multi_website/__manifest__.py index bd3f61c..74d089c 100644 --- a/mail_multi_website/__manifest__.py +++ b/mail_multi_website/__manifest__.py @@ -1,7 +1,7 @@ # Copyright 2018 Ivan Yelizariev # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { - "name": """Email Addresses and Templates per Website""", + "name": """Multi-Brand Mailing""", "summary": """Use single Backend to manage several Websites""", "category": "Discuss", # "live_test_url": "http://apps.it-projects.info/shop/product/website-multi-company?version=11.0", diff --git a/mail_multi_website/doc/index.rst b/mail_multi_website/doc/index.rst index 95e9938..0c0f475 100644 --- a/mail_multi_website/doc/index.rst +++ b/mail_multi_website/doc/index.rst @@ -1,6 +1,6 @@ -=========================================== - Email Addresses and Templates per Website -=========================================== +===================== + Multi-Brand Mailing +===================== Installation ============ diff --git a/mail_multi_website/static/description/index.html b/mail_multi_website/static/description/index.html index 4b57adf..60d49e1 100644 --- a/mail_multi_website/static/description/index.html +++ b/mail_multi_website/static/description/index.html @@ -1,7 +1,7 @@
-

Email Addresses and Templates per Website +

Multi-Brand Mailing

Use single Backend to manage several Websites

diff --git a/mail_private/__init__.py b/mail_private/__init__.py index a9e3372..ac86c5f 100644 --- a/mail_private/__init__.py +++ b/mail_private/__init__.py @@ -1,2 +1,3 @@ +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html) from . import models diff --git a/mail_private/__manifest__.py b/mail_private/__manifest__.py index 0a32ca1..42a296b 100644 --- a/mail_private/__manifest__.py +++ b/mail_private/__manifest__.py @@ -1,9 +1,17 @@ +# Copyright 2016 x620 +# Copyright 2016 Ilmir Karamov +# Copyright 2016 Ivan Yelizariev +# Copyright 2017 Artyom Losev +# Copyright 2018 Ruslan Ronzhin +# Copyright 2018 Kolushov Alexandr +# Copyright 2019 Artem Rafailov +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). { "name": """Internal Messaging""", "summary": """Send private messages to specified recipients, regardless of who are in followers list.""", "category": "Discuss", "images": ['images/mail_private_image.png'], - "version": "11.0.1.1.0", + "version": "11.0.1.2.0", "application": False, "author": "IT-Projects LLC, Pavel Romanchenko", diff --git a/mail_private/doc/changelog.rst b/mail_private/doc/changelog.rst index 4a5f5f0..f642a3e 100644 --- a/mail_private/doc/changelog.rst +++ b/mail_private/doc/changelog.rst @@ -1,3 +1,8 @@ +`1.2.0` +------- + +- **New**: added ability to select channels for private message sending. + `1.1.0` ------- diff --git a/mail_private/full_composer_wizard.xml b/mail_private/full_composer_wizard.xml index 9f57a20..46daeb5 100644 --- a/mail_private/full_composer_wizard.xml +++ b/mail_private/full_composer_wizard.xml @@ -1,4 +1,8 @@ + + diff --git a/mail_private/i18n/mail_private.pot b/mail_private/i18n/mail_private.pot index 90f25bb..312ec8b 100644 --- a/mail_private/i18n/mail_private.pot +++ b/mail_private/i18n/mail_private.pot @@ -34,6 +34,11 @@ msgstr "" msgid "Dummy action" msgstr "" +#. module: mail_private +#: model:ir.model,name:mail_private.model_mail_thread +msgid "Email Thread" +msgstr "" + #. module: mail_private #: model:ir.model,name:mail_private.model_mail_compose_message msgid "Email composition wizard" @@ -60,7 +65,7 @@ msgstr "" #. module: mail_private #. openerp-web -#: code:addons/mail_private/static/src/xml/mail_private.xml:6 +#: code:addons/mail_private/static/src/xml/mail_private.xml:12 #, python-format msgid "Send a message to specified recipients only" msgstr "" @@ -75,21 +80,21 @@ msgstr "" #. module: mail_private #. openerp-web -#: code:addons/mail_private/static/src/xml/mail_private.xml:6 +#: code:addons/mail_private/static/src/xml/mail_private.xml:12 #, python-format msgid "Send internal message" msgstr "" #. module: mail_private #. openerp-web -#: code:addons/mail_private/static/src/xml/mail_private.xml:12 +#: code:addons/mail_private/static/src/xml/mail_private.xml:18 #, python-format msgid "To: Followers of" msgstr "" #. module: mail_private #. openerp-web -#: code:addons/mail_private/static/src/xml/mail_private.xml:23 +#: code:addons/mail_private/static/src/xml/mail_private.xml:39 #, python-format msgid "Uncheck all" msgstr "" @@ -110,7 +115,7 @@ msgstr "" #. module: mail_private #. openerp-web -#: code:addons/mail_private/static/src/xml/mail_private.xml:17 +#: code:addons/mail_private/static/src/xml/mail_private.xml:23 #, python-format msgid "this document" msgstr "" diff --git a/mail_private/models.py b/mail_private/models.py index ae63b3f..104c3f4 100644 --- a/mail_private/models.py +++ b/mail_private/models.py @@ -1,3 +1,9 @@ +# Copyright 2016 x620 +# Copyright 2016 manawi +# Copyright 2017 Artyom Losev +# Copyright 2019 Artem Rafailov +# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). + from odoo import models, fields, api @@ -13,17 +19,16 @@ class MailMessage(models.Model): is_private = fields.Boolean(string='Send Internal Message') def send_recepients_for_internal_message(self, model, domain): - result = [] + result = {'partners': [], 'channels': []} default_resource = self.env[model].search(domain) follower_ids = default_resource.message_follower_ids - internal_ids = self.get_internal_users_ids() recipient_ids = [r.partner_id for r in follower_ids if r.partner_id] - # channel_ids = [c.channel_id for c in follower_ids if c.channel_id] + channel_ids = [c.channel_id for c in follower_ids if c.channel_id] for recipient in recipient_ids: - result.append({ - 'checked': recipient.user_ids.id in internal_ids, + result['partners'].append({ + 'checked': recipient.user_ids.id and not any(recipient.user_ids.mapped('share')), 'partner_id': recipient.id, 'full_name': recipient.name, 'name': recipient.name, @@ -31,14 +36,14 @@ class MailMessage(models.Model): 'reason': 'Recipient' }) - # for channel in channel_ids: - # result.append({ - # 'checked': True, - # 'channel_id': channel.id, - # 'full_name': channel, - # 'name': '# '+channel.name, - # 'reason': 'Channel', - # }) + for channel in channel_ids: + result['channels'].append({ + 'checked': True, + 'channel_id': channel.id, + 'full_name': channel.name, + 'name': '# '+channel.name, + 'reason': 'Channel', + }) return result @api.multi @@ -54,7 +59,6 @@ class MailMessage(models.Model): """ Compute recipients to notify based on specified recipients and document followers. Delegate notification to partners to send emails and bus notifications and to channels to broadcast messages on channels """ - group_user = self.env.ref('base.group_user') # have a sudoed copy to manipulate partners (public can go here with website modules like forum / blog / ... ) self_sudo = self.sudo() @@ -62,16 +66,6 @@ class MailMessage(models.Model): partners_sudo = self_sudo.partner_ids channels_sudo = self_sudo.channel_ids - if self_sudo.subtype_id and self.model and self.res_id: - followers = self_sudo.env['mail.followers'].search([ - ('res_model', '=', self.model), - ('res_id', '=', self.res_id), - ('subtype_ids', 'in', self_sudo.subtype_id.id), - ]) - if self_sudo.subtype_id.internal: - followers = followers.filtered(lambda fol: fol.channel_id or (fol.partner_id.user_ids and group_user in fol.partner_id.user_ids[0].mapped('groups_id'))) - channels_sudo |= followers.mapped('channel_id') - # remove author from notified partners if not self._context.get('mail_notify_author', False) and self_sudo.author_id: partners_sudo = partners_sudo - self_sudo.author_id @@ -108,6 +102,16 @@ class MailMessage(models.Model): return True - def get_internal_users_ids(self): - internal_users_ids = self.env['res.users'].search([('share', '=', False)]).ids - return internal_users_ids + +class MailThread(models.AbstractModel): + _inherit = 'mail.thread' + + @api.multi + @api.returns('self', lambda value: value.id) + def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False, + attachments=None, content_subtype='html', **kwargs): + if 'channel_ids' in kwargs: + kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']] + return super(MailThread, self).message_post(body, subject, message_type, + subtype, parent_id, attachments, + content_subtype, **kwargs) diff --git a/mail_private/static/src/css/mail_private.css b/mail_private/static/src/css/mail_private.css new file mode 100644 index 0000000..083365d --- /dev/null +++ b/mail_private/static/src/css/mail_private.css @@ -0,0 +1,10 @@ +.o_composer_suggested_channels{ + margin-top: -5px; +} + +.oe_composer_uncheck{ + float: bottom; + margin-top:5px; + margin-left:-5px; +} + diff --git a/mail_private/static/src/js/mail_private.js b/mail_private/static/src/js/mail_private.js index 4b3a7d0..d1f0844 100644 --- a/mail_private/static/src/js/mail_private.js +++ b/mail_private/static/src/js/mail_private.js @@ -1,8 +1,9 @@ -/* Copyright 2016-2018 Ivan Yelizariev - Copyright 2016 manavi - Copyright 2017-2018 Artyom Losev - Copyright 2018 Kolushov Alexandr - License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */ +/* Copyright 2016 x620 + Copyright 2016 Ivan Yelizariev + Copyright 2016 manawi + Copyright 2017 Artyom Losev + Copyright 2019 Artem Rafailov + License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). */ odoo.define('mail_private', function (require) { 'use strict'; @@ -29,7 +30,8 @@ Chatter.include({ this.fetch_recipients_for_internal_message().then(function (data) { self._openComposer({ is_private: true, - suggested_partners: data + suggested_partners: data["partners"], + suggested_channels: data["channels"], }); }); }, @@ -48,7 +50,8 @@ Chatter.include({ record_name: this.record_name, default_body: old_composer && old_composer.$input && old_composer.$input.val(), default_mention_selections: old_composer && old_composer.mention_get_listener_selections(), - is_private: options.is_private + is_private: options.is_private, + suggested_channels: options.suggested_channels }); this.composer.on('input_focused', this, function () { this.composer.mention_set_prefetched_partners(this.mentionSuggestions || []); @@ -64,6 +67,7 @@ Chatter.include({ self.composer.on('post_message', self, function (message) { if (options.is_private) { self.composer.options.is_log = true; + self.composer.options.is_private = options.is_private; } self.fields.thread.postMessage(message).then(function () { @@ -94,16 +98,18 @@ Chatter.include({ method: 'send_recepients_for_internal_message', args: [[], self.context.default_model, follower_ids_domain] }).then(function (res) { - return _.filter(res, function (obj) { + res["partners"] = _.filter(res["partners"], function (obj) { return obj.partner_id !== session.partner_id; }); + return res; }); - } + }, }); ChatterComposer.include({ init: function (parent, model, suggested_partners, options) { this._super(parent, model, suggested_partners, options); + this.suggested_channels = options.suggested_channels; this.events['click .oe_composer_uncheck'] = 'on_uncheck_recipients'; if (typeof options.is_private === 'undefined') { // otherwise it causes an error in context creating function @@ -154,6 +160,9 @@ ChatterComposer.include({ this.$('.o_composer_suggested_partners input:checked').each(function() { $(this).prop('checked', false); }); + this.$('.o_composer_suggested_channels input:checked').each(function() { + $(this).prop('checked', false); + }); }, on_open_full_composer: function() { @@ -215,16 +224,15 @@ ChatterComposer.include({ checked_partners = _.uniq(_.filter(checked_partners, function (obj) { return obj.reason !== 'Channel'; })); - this.get_checked_channel_ids(); return checked_partners; }, get_checked_channel_ids: function () { var self = this; var checked_channels = []; - this.$('.o_composer_suggested_partners input:checked').each(function() { + this.$('.o_composer_suggested_channels input:checked').each(function() { var full_name = $(this).data('fullname'); - checked_channels = checked_channels.concat(_.filter(self.suggested_partners, function(item) { + checked_channels = checked_channels.concat(_.filter(self.suggested_channels, function(item) { return full_name === item.full_name; })); }); diff --git a/mail_private/static/src/xml/mail_private.xml b/mail_private/static/src/xml/mail_private.xml index baadbb5..188d2b3 100644 --- a/mail_private/static/src/xml/mail_private.xml +++ b/mail_private/static/src/xml/mail_private.xml @@ -1,9 +1,15 @@ +