diff --git a/addons/mail/static/src/core/common/messaging_service.js b/addons/mail/static/src/core/common/messaging_service.js index 1ab53680565..fc4ec2c8228 100644 --- a/addons/mail/static/src/core/common/messaging_service.js +++ b/addons/mail/static/src/core/common/messaging_service.js @@ -98,6 +98,7 @@ export class Messaging { }); this.store.hasLinkPreviewFeature = data.hasLinkPreviewFeature; this.store.initBusId = data.initBusId; + this.store.odoobotOnboarding = data.odoobotOnboarding; this.isReady.resolve(data); this.store.isMessagingReady = true; } diff --git a/addons/mail/static/src/core/common/store_service.js b/addons/mail/static/src/core/common/store_service.js index 17e0b84f36f..d2d710963e1 100644 --- a/addons/mail/static/src/core/common/store_service.js +++ b/addons/mail/static/src/core/common/store_service.js @@ -90,6 +90,7 @@ export class Store { /** @type {import("@mail/core/common/persona_model").Persona} */ odoobot = null; + odoobotOnboarding; /** @type {Object.} */ personas = {}; diff --git a/addons/mail/static/src/discuss/core/web/discuss_core_web_service.js b/addons/mail/static/src/discuss/core/web/discuss_core_web_service.js index f2c4337a815..b19b9d6dbe3 100644 --- a/addons/mail/static/src/discuss/core/web/discuss_core_web_service.js +++ b/addons/mail/static/src/discuss/core/web/discuss_core_web_service.js @@ -48,13 +48,15 @@ export class DiscussCoreWeb { this.env.bus.addEventListener( "discuss.channel/new_message", ({ detail: { channel, message } }) => { - if ( - !this.ui.isSmall && - channel.correspondent !== this.store.odoobot && - !message.isSelfAuthored - ) { - this.chatWindowService.insert({ thread: channel }); + if (this.ui.isSmall || message.isSelfAuthored) { + return; } + if (channel.correspondent === this.store.odoobot && this.store.odoobotOnboarding) { + // this cancels odoobot onboarding auto-opening of chat window + this.store.odoobotOnboarding = false; + return; + } + this.chatWindowService.insert({ thread: channel }); } ); this.busService.subscribe("mail.record/insert", (payload) => { diff --git a/addons/mail_bot/models/res_users.py b/addons/mail_bot/models/res_users.py index b9ccf7d230a..c9309be48a8 100644 --- a/addons/mail_bot/models/res_users.py +++ b/addons/mail_bot/models/res_users.py @@ -25,9 +25,13 @@ class Users(models.Model): return super().SELF_READABLE_FIELDS + ['odoobot_state'] def _init_messaging(self): + odoobot_onboarding = False if self.odoobot_state in [False, 'not_initialized'] and self._is_internal(): + odoobot_onboarding = True self._init_odoobot() - return super()._init_messaging() + res = super()._init_messaging() + res['odoobotOnboarding'] = odoobot_onboarding + return res def _init_odoobot(self): self.ensure_one() diff --git a/addons/test_discuss_full/tests/test_performance.py b/addons/test_discuss_full/tests/test_performance.py index 13e8424a72e..acf1d4deb44 100644 --- a/addons/test_discuss_full/tests/test_performance.py +++ b/addons/test_discuss_full/tests/test_performance.py @@ -126,6 +126,7 @@ class TestDiscussFullPerformance(HttpCase): 'hasLinkPreviewFeature': True, 'needaction_inbox_counter': 1, 'starred_counter': 1, + 'odoobotOnboarding': False, 'channels': [ { 'authorizedGroupFullName': self.group_user.full_name,