From eaf2fb3c88a03a72de74d7030655aec81ee5575a Mon Sep 17 00:00:00 2001 From: Denis Mudarisov Date: Mon, 21 Dec 2020 12:08:22 +0500 Subject: [PATCH 1/3] :ambulance: fix race condition with mail module initialization Because mail module in Odoo 11 version doesn't allow to extend, we repeat initialization. That may conflict with original initialization. In order to solve that, we wait for original initialization and only then start the process patch from @yelizariev --- mail_base/__manifest__.py | 2 +- mail_base/doc/changelog.rst | 5 +++++ mail_base/static/lib/base.js | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mail_base/__manifest__.py b/mail_base/__manifest__.py index 6a68514..27fad67 100644 --- a/mail_base/__manifest__.py +++ b/mail_base/__manifest__.py @@ -7,7 +7,7 @@ "summary": """Makes Mail extendable""", "category": "Discuss", "images": ["images/mail_base_image.png"], - "version": "11.0.1.1.1", + "version": "11.0.1.1.2", "author": "IT-Projects LLC, Pavel Romanchenko", "support": "apps@itpp.dev", "website": "https://it-projects.info", diff --git a/mail_base/doc/changelog.rst b/mail_base/doc/changelog.rst index 83589b0..cd75d3e 100644 --- a/mail_base/doc/changelog.rst +++ b/mail_base/doc/changelog.rst @@ -1,3 +1,8 @@ +`1.1.2` +------- + +**FIX**: random initialization errors + `1.1.1` ------- diff --git a/mail_base/static/lib/base.js b/mail_base/static/lib/base.js index fa9dcbe..609322d 100644 --- a/mail_base/static/lib/base.js +++ b/mail_base/static/lib/base.js @@ -123,6 +123,8 @@ ChatAction.include({ } }); +function init_chat_manager(){ + chat_manager.notify_incoming_message = function (msg, options) { if (bus.is_odoo_focused() && options.is_displayed) { // no need to notify @@ -1409,11 +1411,17 @@ chat_manager.search_partner = function (search_val, limit) { }); } +}; // init_chat_manager + +chat_manager.is_ready = chat_manager.is_ready.then(function(){ + +init_chat_manager(); chat_manager.start(); bus.off('notification'); bus.on('notification', null, function () { chat_manager.on_notification.apply(chat_manager, arguments); }); +}); return { ODOOBOT_ID: ODOOBOT_ID, From 12a2230674ac07860d8a6099f3397bcd4d5ea0f2 Mon Sep 17 00:00:00 2001 From: Denis Mudarisov Date: Mon, 21 Dec 2020 20:39:42 +0500 Subject: [PATCH 2/3] :ambulance: fix random error when we open the pop-up chat window and reload the page --- mail_to/__manifest__.py | 3 ++- mail_to/doc/changelog.rst | 5 +++++ mail_to/static/src/js/mail_to.js | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mail_to/__manifest__.py b/mail_to/__manifest__.py index 3b0841a..5013d8d 100644 --- a/mail_to/__manifest__.py +++ b/mail_to/__manifest__.py @@ -2,13 +2,14 @@ # Copyright 2016,2020 Ivan Yelizariev # Copyright 2018 Ruslan Ronzhin # Copyright 2019 Artem Rafailov +# Copyright 2020 Denis Mudarisov # License MIT (https://opensource.org/licenses/MIT). { "name": """Show message recipients""", "summary": """Allows you be sure, that all discussion participants were notified""", "category": "Discuss", "images": ["images/1.png"], - "version": "11.0.1.1.1", + "version": "11.0.1.1.2", "author": "IT-Projects LLC, Pavel Romanchenko", "support": "apps@itpp.dev", "website": "https://it-projects.info", diff --git a/mail_to/doc/changelog.rst b/mail_to/doc/changelog.rst index de0ff64..2aa1cf0 100644 --- a/mail_to/doc/changelog.rst +++ b/mail_to/doc/changelog.rst @@ -1,3 +1,8 @@ +`1.1.2` +------- + +- **Fix** if open the pop-up chat window and reload the page, then an error might occur randomly + `1.1.1` ------- diff --git a/mail_to/static/src/js/mail_to.js b/mail_to/static/src/js/mail_to.js index 867580f..01befa3 100644 --- a/mail_to/static/src/js/mail_to.js +++ b/mail_to/static/src/js/mail_to.js @@ -2,12 +2,15 @@ * Copyright 2016-2017,2020 Ivan Yelizariev * Copyright 2017 Artyom Losev * Copyright 2019 Artem Rafailov + * Copyright 2020 Denis Mudarisov * License MIT (https://opensource.org/licenses/MIT). */ odoo.define("mail_to.MailTo", function(require) { "use strict"; var chat_manager = require("mail_base.base").chat_manager; + chat_manager.is_ready = chat_manager.is_ready.then(function(){ + var make_message_super = chat_manager.make_message; chat_manager.make_message = function(data) { var msg = make_message_super.call(this, data); @@ -35,6 +38,7 @@ odoo.define("mail_to.MailTo", function(require) { msg.more_recipients = more_recipients; return msg; }; + }); return chat_manager; }); From 85e5070064d519229e0fe270372ed08f0d214615 Mon Sep 17 00:00:00 2001 From: Denis Mudarisov Date: Tue, 22 Dec 2020 10:11:51 +0500 Subject: [PATCH 3/3] :rainbow: pre-commit --- .github/workflows/DINAR-PORT.yml | 8 ++--- mail_to/doc/changelog.rst | 2 +- mail_to/static/src/js/mail_to.js | 51 +++++++++++++-------------- mail_to/static/src/js/test_mail_to.js | 2 +- mail_to/static/src/xml/recipient.xml | 24 +++++++------ 5 files changed, 45 insertions(+), 42 deletions(-) diff --git a/.github/workflows/DINAR-PORT.yml b/.github/workflows/DINAR-PORT.yml index 2bbd3e7..88486e7 100644 --- a/.github/workflows/DINAR-PORT.yml +++ b/.github/workflows/DINAR-PORT.yml @@ -96,7 +96,7 @@ jobs: --no-commit \ 2> $LOG_FILE || true cat $LOG_FILE - + # remove colors sed -r -i "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" $LOG_FILE # escape character @@ -104,9 +104,9 @@ jobs: body=$(cat $LOG_FILE) body="${body//'%'/'%25'}" body="${body//$'\n'/'%0A'}" - body="${body//$'\r'/'%0D'}" + body="${body//$'\r'/'%0D'}" echo "MIGRATOR_LOGS=$body" >> $GITHUB_ENV - + git add -A git commit -m ":arrow_up:${{ env.PORT_TO_BRANCH_TAGS }} OCA/odoo-module-migrator @@ -137,7 +137,7 @@ jobs: number: ${{ steps.cpr.outputs.pull-request-number }} comment: | [Migrator](https://github.com/OCA/odoo-module-migrator/)'s logs: - + ``` ${{ env.MIGRATOR_LOGS }} ``` diff --git a/mail_to/doc/changelog.rst b/mail_to/doc/changelog.rst index 2aa1cf0..6b97eb6 100644 --- a/mail_to/doc/changelog.rst +++ b/mail_to/doc/changelog.rst @@ -1,7 +1,7 @@ `1.1.2` ------- -- **Fix** if open the pop-up chat window and reload the page, then an error might occur randomly +- **Fix:** if open the pop-up chat window and reload the page, then an error might occur randomly `1.1.1` ------- diff --git a/mail_to/static/src/js/mail_to.js b/mail_to/static/src/js/mail_to.js index 01befa3..caeca64 100644 --- a/mail_to/static/src/js/mail_to.js +++ b/mail_to/static/src/js/mail_to.js @@ -4,40 +4,39 @@ * Copyright 2019 Artem Rafailov * Copyright 2020 Denis Mudarisov * License MIT (https://opensource.org/licenses/MIT). */ -odoo.define("mail_to.MailTo", function(require) { +odoo.define("mail_to.MailTo", function (require) { "use strict"; var chat_manager = require("mail_base.base").chat_manager; - chat_manager.is_ready = chat_manager.is_ready.then(function(){ - - 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); - if (!msg.partner_ids && !msg.channel_names) { - return msg; - } + chat_manager.is_ready = chat_manager.is_ready.then(function () { + 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); + 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 += "; "; + 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; - }; + msg.more_recipients = more_recipients; + return msg; + }; }); return chat_manager; diff --git a/mail_to/static/src/js/test_mail_to.js b/mail_to/static/src/js/test_mail_to.js index 95db0a8..9c164df 100644 --- a/mail_to/static/src/js/test_mail_to.js +++ b/mail_to/static/src/js/test_mail_to.js @@ -1,6 +1,6 @@ /* Copyright 2018 Artem Rafailov License MIT (https://opensource.org/licenses/MIT).*/ -odoo.define("mail_to.tour", function(require) { +odoo.define("mail_to.tour", function (require) { "use strict"; var tour = require("web_tour.tour"); diff --git a/mail_to/static/src/xml/recipient.xml b/mail_to/static/src/xml/recipient.xml index feccf3c..fab8882 100644 --- a/mail_to/static/src/xml/recipient.xml +++ b/mail_to/static/src/xml/recipient.xml @@ -8,8 +8,8 @@ - To: - To: + To: + To: - ; + ; ; + > + ; + @@ -35,9 +37,9 @@ class="recipient_link" > - ; + + ; + @@ -46,10 +48,12 @@ t-if="message.recipients.length > message.more_recipients_value" > - and more - + /> + more +