diff --git a/addons/barcodes/static/src/js/barcode_events.js b/addons/barcodes/static/src/js/barcode_events.js deleted file mode 100644 index 735d4f8d56f..00000000000 --- a/addons/barcodes/static/src/js/barcode_events.js +++ /dev/null @@ -1,24 +0,0 @@ -/** @odoo-module **/ - -/** - * BarcodeEvents has been removed and replaced by the barcode service. - * - * This file is a temporary service to remap barcode events from new barcode - * service to core.bus (which was the purpose of BarcodeEvents). - * - * @TODO: remove this as soon as all barcode code is using new barcode service - */ - -import { registry } from "@web/core/registry"; -import core from "@web/legacy/js/services/core"; - -export const barcodeRemapperService = { - dependencies: ["barcode"], - start(env, { barcode }) { - barcode.bus.addEventListener("barcode_scanned", ev => { - const { barcode, target } = ev.detail; - core.bus.trigger('barcode_scanned', barcode, target); - }); - }, -}; -registry.category("services").add("barcode_remapper", barcodeRemapperService); diff --git a/addons/barcodes/static/tests/mobile/barcode_mobile_tests.js b/addons/barcodes/static/tests/mobile/barcode_mobile_tests.js index fb43673e445..9bef5e53423 100644 --- a/addons/barcodes/static/tests/mobile/barcode_mobile_tests.js +++ b/addons/barcodes/static/tests/mobile/barcode_mobile_tests.js @@ -1,7 +1,6 @@ /** @odoo-module **/ import {barcodeService} from "@barcodes/barcode_service"; - import {barcodeRemapperService} from "@barcodes/js/barcode_events"; import { makeTestEnv } from "@web/../tests/helpers/mock_env"; import { registry } from "@web/core/registry"; import testUtils from "@web/../tests/legacy/helpers/test_utils"; @@ -30,8 +29,6 @@ barcodeService.maxTimeBetweenKeysInMs = 0; barcodeService.isMobileChrome = true; registry.category("services").add("barcode", barcodeService, { force: true}); - // remove this one later - registry.category("services").add("barcode_remapper", barcodeRemapperService); this.env = makeTestEnv(); }, after() { diff --git a/addons/mrp_subcontracting/__manifest__.py b/addons/mrp_subcontracting/__manifest__.py index 994cb9998ff..220b5682dcc 100644 --- a/addons/mrp_subcontracting/__manifest__.py +++ b/addons/mrp_subcontracting/__manifest__.py @@ -90,7 +90,6 @@ 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/jquery.js', - 'web/static/src/legacy/js/core/bus.js', 'web/static/src/legacy/js/core/class.js', 'web/static/src/legacy/js/core/dialog.js', 'web/static/src/legacy/xml/dialog.xml', @@ -98,7 +97,6 @@ 'web/static/src/legacy/js/core/mixins.js', 'web/static/src/legacy/js/core/service_mixins.js', 'web/static/src/legacy/js/core/widget.js', - 'web/static/src/legacy/js/services/core.js', ('include', 'web._assets_bootstrap'), diff --git a/addons/payment/static/src/js/express_checkout_form.js b/addons/payment/static/src/js/express_checkout_form.js index 4297ed1062a..2e7d4870914 100644 --- a/addons/payment/static/src/js/express_checkout_form.js +++ b/addons/payment/static/src/js/express_checkout_form.js @@ -1,7 +1,7 @@ /** @odoo-module */ -import core from '@web/legacy/js/services/core'; import publicWidget from '@web/legacy/js/public/public_widget'; +import { Component } from '@odoo/owl'; publicWidget.registry.PaymentExpressCheckoutForm = publicWidget.Widget.extend({ selector: 'form[name="o_payment_express_checkout_form"]', @@ -19,7 +19,7 @@ publicWidget.registry.PaymentExpressCheckoutForm = publicWidget.Widget.extend({ await this._prepareExpressCheckoutForm(expressCheckoutForm.dataset); } // Monitor updates of the amount on eCommerce's cart pages. - core.bus.on('cart_amount_changed', this, this._updateAmount.bind(this)); + Component.env.bus.addEventListener('cart_amount_changed', (ev) => this._updateAmount(...ev.detail)); }, //-------------------------------------------------------------------------- diff --git a/addons/portal/static/src/js/portal_chatter.js b/addons/portal/static/src/js/portal_chatter.js index 4126b99dcf9..d2fc480a14a 100644 --- a/addons/portal/static/src/js/portal_chatter.js +++ b/addons/portal/static/src/js/portal_chatter.js @@ -1,13 +1,12 @@ /** @odoo-module **/ -import core from "@web/legacy/js/services/core"; import { renderToElement } from "@web/core/utils/render"; import dom from "@web/legacy/js/core/dom"; import publicWidget from "@web/legacy/js/public/public_widget"; import portalComposer from "@portal/js/portal_composer"; import { range } from "@web/core/utils/numbers"; -import { markup } from "@odoo/owl"; +import { Component, markup } from "@odoo/owl"; /** * Widget PortalChatter @@ -67,7 +66,7 @@ var PortalChatter = publicWidget.Widget.extend({ // bind bus event: this (portal.chatter) and 'portal.rating.composer' in portal_rating // are separate and sibling widgets, this event is to be triggered from portal.rating.composer, // hence bus event is bound to achieve usage of the event in another widget. - core.bus.on('reload_chatter_content', this, this._reloadChatterContent); + Component.env.bus.addEventListener('reload_chatter_content', (ev) => this._reloadChatterContent(ev.detail)); return Promise.all([this._super.apply(this, arguments), this._reloadComposer()]); }, diff --git a/addons/portal/static/src/js/portal_composer.js b/addons/portal/static/src/js/portal_composer.js index a6bd15a0820..fed8af22af9 100644 --- a/addons/portal/static/src/js/portal_composer.js +++ b/addons/portal/static/src/js/portal_composer.js @@ -2,10 +2,10 @@ import { _t } from "@web/core/l10n/translation"; import { escape } from "@web/core/utils/strings"; -import core from "@web/legacy/js/services/core"; import { renderToElement } from "@web/core/utils/render"; import publicWidget from "@web/legacy/js/public/public_widget"; import { post } from "@web/core/network/http_service"; +import { Component } from "@odoo/owl"; /** * Widget PortalComposer @@ -197,7 +197,7 @@ var PortalComposer = publicWidget.Widget.extend({ */ _chatterPostMessage: async function (route) { const result = await this.rpc(route, this._prepareMessageData()); - core.bus.trigger('reload_chatter_content', result); + Component.env.bus.trigger('reload_chatter_content', result); return result; }, }); diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index 911f8c5ad50..5cee3e99a00 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -140,7 +140,6 @@ 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/jquery.js', - 'web/static/src/legacy/js/core/bus.js', 'web/static/src/legacy/js/core/class.js', 'web/static/src/legacy/js/core/dialog.js', 'web/static/src/legacy/xml/dialog.xml', @@ -148,7 +147,6 @@ 'web/static/src/legacy/js/core/mixins.js', 'web/static/src/legacy/js/core/service_mixins.js', 'web/static/src/legacy/js/core/widget.js', - 'web/static/src/legacy/js/services/core.js', ('include', 'web._assets_bootstrap_backend'), 'base/static/src/css/modules.css', diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 3d028b75cbe..d27bab33e1e 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -92,7 +92,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/jquery.js', - 'web/static/src/legacy/js/core/bus.js', 'web/static/src/legacy/js/core/class.js', 'web/static/src/legacy/js/core/dialog.js', 'web/static/src/legacy/xml/dialog.xml', @@ -100,7 +99,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/js/core/mixins.js', 'web/static/src/legacy/js/core/service_mixins.js', 'web/static/src/legacy/js/core/widget.js', - 'web/static/src/legacy/js/services/core.js', 'base/static/src/css/modules.css', @@ -214,7 +212,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/jquery.js', - 'web/static/src/legacy/js/core/bus.js', 'web/static/src/legacy/js/core/class.js', 'web/static/src/legacy/js/core/dialog.js', 'web/static/src/legacy/xml/dialog.xml', @@ -222,7 +219,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/js/core/mixins.js', 'web/static/src/legacy/js/core/service_mixins.js', 'web/static/src/legacy/js/core/widget.js', - 'web/static/src/legacy/js/services/core.js', 'web/static/src/env.js', 'web/static/src/core/utils/transitions.scss', # included early because used by other files diff --git a/addons/web/static/src/legacy/js/core/bus.js b/addons/web/static/src/legacy/js/core/bus.js deleted file mode 100644 index f8107a81258..00000000000 --- a/addons/web/static/src/legacy/js/core/bus.js +++ /dev/null @@ -1,16 +0,0 @@ -/** @odoo-module **/ - -import Class from "@web/legacy/js/core/class"; -import mixins from "@web/legacy/js/core/mixins"; - -/** - * Event Bus used to bind events scoped in the current instance - * - * @class Bus - */ -export default Class.extend(mixins.EventDispatcherMixin, { - init: function (parent) { - mixins.EventDispatcherMixin.init.call(this); - this.setParent(parent); - }, -}); diff --git a/addons/web/static/src/legacy/js/core/dialog.js b/addons/web/static/src/legacy/js/core/dialog.js index d7e80e96764..f39a1b605f1 100644 --- a/addons/web/static/src/legacy/js/core/dialog.js +++ b/addons/web/static/src/legacy/js/core/dialog.js @@ -1,6 +1,5 @@ /** @odoo-module **/ -import core from "@web/legacy/js/services/core"; import dom from "@web/legacy/js/core/dom"; import Widget from "@web/legacy/js/core/widget"; import { _t } from "@web/core/l10n/translation"; @@ -100,8 +99,6 @@ var Dialog = Widget.extend({ this.renderHeader = options.renderHeader; this.renderFooter = options.renderFooter; this.onForceClose = options.onForceClose; - - core.bus.on('close_dialogs', this, this.destroy.bind(this)); }, /** * Wait for XML dependencies and instantiate the modal structure (except @@ -211,9 +208,6 @@ var Dialog = Widget.extend({ if (options && options.shouldFocusButtons) { self._onFocusControlButton(); } - - // Notifies new webclient to adjust UI active element - core.bus.trigger("legacy_dialog_opened", self); }); return self; @@ -245,11 +239,6 @@ var Dialog = Widget.extend({ return; } - if (this.el) { - // Notifies new webclient to adjust UI active element - core.bus.trigger("legacy_dialog_destroyed", this); - } - // Triggers the onForceClose event if the callback is defined if (this.onForceClose) { this.onForceClose(); diff --git a/addons/web/static/src/legacy/js/core/dom.js b/addons/web/static/src/legacy/js/core/dom.js index 4deee664908..636feda7f10 100644 --- a/addons/web/static/src/legacy/js/core/dom.js +++ b/addons/web/static/src/legacy/js/core/dom.js @@ -11,7 +11,6 @@ import { uniqueId } from "@web/core/utils/functions"; import { delay } from "@web/core/utils/concurrency"; -import core from "@web/legacy/js/services/core"; import { localization } from "@web/core/l10n/localization"; /** @@ -27,7 +26,6 @@ function _notify(content, callbacks) { c.widget.on_attach_callback(c.callback_args); } }); - core.bus.trigger('DOM_updated', content); } var dom = { @@ -139,12 +137,6 @@ var dom = { $textarea.data("auto_resize", true); $textarea.on('input focus change', resize); - if (options.parent) { - core.bus.on('DOM_updated', options.parent, function () { - resize(); - removeVerticalResize(); - }); - } }, /** * @return {HTMLElement|null} diff --git a/addons/web/static/src/legacy/js/services/core.js b/addons/web/static/src/legacy/js/services/core.js deleted file mode 100644 index 8318c3835f3..00000000000 --- a/addons/web/static/src/legacy/js/services/core.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @odoo-module **/ - -import Bus from "@web/legacy/js/core/bus"; - -export const bus = new Bus(); -export default { bus }; diff --git a/addons/web/static/tests/setup.js b/addons/web/static/tests/setup.js index a82c010a927..cfbad34f680 100644 --- a/addons/web/static/tests/setup.js +++ b/addons/web/static/tests/setup.js @@ -1,6 +1,5 @@ /** @odoo-module **/ -import LegacyBus from "@web/legacy/js/core/bus"; import { assets, templates } from "@web/core/assets"; import { browser, makeRAMLocalStorage } from "@web/core/browser/browser"; import { patchTimeZone, patchWithCleanup } from "@web/../tests/helpers/utils"; @@ -201,19 +200,6 @@ function patchBodyAddEventListener() { }); } -function patchLegacyBus() { - // patch core.bus.on to automatically remove listners bound on the legacy bus - // during a test (e.g. during the deployment of a service) - patchWithCleanup(LegacyBus.prototype, { - on() { - super.on(...arguments); - registerCleanup(() => { - this.off(...arguments); - }); - }, - }); -} - function patchOdoo() { patchWithCleanup(odoo, { debug: "", @@ -367,7 +353,6 @@ export async function setupTests() { patchCookie(); patchBodyAddEventListener(); patchEventBus(); - patchLegacyBus(); patchOdoo(); patchSessionInfo(); patchOwlApp(); diff --git a/addons/web_editor/__manifest__.py b/addons/web_editor/__manifest__.py index 122a9fd1c32..2cd8663fa1e 100644 --- a/addons/web_editor/__manifest__.py +++ b/addons/web_editor/__manifest__.py @@ -79,7 +79,6 @@ Odoo Web Editor widget. 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/jquery.js', - 'web/static/src/legacy/js/core/bus.js', 'web/static/src/legacy/js/core/class.js', 'web/static/src/legacy/js/core/dialog.js', 'web/static/src/legacy/xml/dialog.xml', @@ -87,7 +86,6 @@ Odoo Web Editor widget. 'web/static/src/legacy/js/core/mixins.js', 'web/static/src/legacy/js/core/service_mixins.js', 'web/static/src/legacy/js/core/widget.js', - 'web/static/src/legacy/js/services/core.js', ('include', 'web_editor.assets_wysiwyg'), ('include', 'web_editor.assets_legacy_wysiwyg'), ], diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 6d4742608bd..84b2d6f1f23 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2,7 +2,6 @@ import { Mutex } from "@web/core/utils/concurrency"; import { clamp } from "@web/core/utils/numbers"; -import core from "@web/legacy/js/services/core"; import Dialog from "@web/legacy/js/core/dialog"; import dom from "@web/legacy/js/core/dom"; import Widget from "@web/legacy/js/core/widget"; @@ -1968,8 +1967,6 @@ var SnippetsMenu = Widget.extend({ // Needed as bootstrap stop the propagation of click events for dropdowns this.$document.on('mouseup.snippets_menu', '.dropdown-toggle', this._onClick); - core.bus.on('deactivate_snippet', this, this._onDeactivateSnippet); - // Adapt overlay covering when the window is resized / content changes this.debouncedCoverUpdate = throttleForAnimation(() => { this.updateCurrentSnippetEditorOverlay(); @@ -2108,7 +2105,6 @@ var SnippetsMenu = Widget.extend({ if (this.debouncedCoverUpdate) { this.debouncedCoverUpdate.cancel(); } - core.bus.off('deactivate_snippet', this, this._onDeactivateSnippet); $(document.body).off('click', this._checkEditorToolbarVisibilityCallback); this.el.ownerDocument.body.classList.remove('editor_has_snippets'); // Dispose BS tooltips. diff --git a/addons/website_event_track/static/src/js/event_track_reminder.js b/addons/website_event_track/static/src/js/event_track_reminder.js index 5c990bd8fa0..e1ed813997f 100644 --- a/addons/website_event_track/static/src/js/event_track_reminder.js +++ b/addons/website_event_track/static/src/js/event_track_reminder.js @@ -1,9 +1,9 @@ /** @odoo-module **/ import { debounce } from "@web/core/utils/timing"; -import core from "@web/legacy/js/services/core"; import publicWidget from "@web/legacy/js/public/public_widget"; import { _t } from "@web/core/l10n/translation"; +import { Component } from "@odoo/owl"; publicWidget.registry.websiteEventTrackReminder = publicWidget.Widget.extend({ selector: '.o_wetrack_js_reminder', @@ -60,11 +60,14 @@ publicWidget.registry.websiteEventTrackReminder = publicWidget.Widget.extend({ type: 'info', }); if (self.reminderOn) { - core.bus.trigger('open_notification_request', 'add_track_to_favorite', { - title: _t('Allow push notifications?'), - body: _t('You have to enable push notifications to get reminders for your favorite tracks.'), - delay: 0 - }); + Component.env.bus.trigger('open_notification_request', [ + 'add_track_to_favorite', + { + title: _t('Allow push notifications?'), + body: _t('You have to enable push notifications to get reminders for your favorite tracks.'), + delay: 0 + }, + ]); } } }); diff --git a/addons/website_payment/static/src/js/payment_form.js b/addons/website_payment/static/src/js/payment_form.js index 76df1329cb7..6f25a7bc915 100644 --- a/addons/website_payment/static/src/js/payment_form.js +++ b/addons/website_payment/static/src/js/payment_form.js @@ -1,7 +1,7 @@ /** @odoo-module **/ -import core from '@web/legacy/js/services/core'; import { _t } from '@web/core/l10n/translation'; +import { Component } from '@odoo/owl'; import PaymentForm from '@payment/js/payment_form'; @@ -16,7 +16,7 @@ PaymentForm.include({ * @override */ async start() { - core.bus.on('update_shipping_cost', this, this._updateShippingCost); + Component.env.bus.addEventListener('update_shipping_cost', (ev) => this._updateShippingCost(ev.detail)); return await this._super.apply(this, arguments); }, diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 97c1b2673f4..52b695bcf9e 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -1,6 +1,5 @@ /** @odoo-module **/ -import core from "@web/legacy/js/services/core"; import publicWidget from "@web/legacy/js/public/public_widget"; import VariantMixin from "@website_sale/js/variant_mixin"; import wSaleUtils from "@website_sale/js/website_sale_utils"; @@ -12,6 +11,7 @@ import { ProductImageViewer } from "@website_sale/js/components/website_sale_ima import { jsonrpc } from "@web/core/network/rpc_service"; import { debounce, throttleForAnimation } from "@web/core/utils/timing"; import { listenSizeChange, SIZES, utils as uiUtils } from "@web/core/ui/ui_service"; +import { Component } from "@odoo/owl"; export const WebsiteSale = publicWidget.Widget.extend(VariantMixin, cartHandlerMixin, { selector: '.oe_website_sale', @@ -209,7 +209,7 @@ export const WebsiteSale = publicWidget.Widget.extend(VariantMixin, cartHandlerM product_id: parseInt($input.data('product-id'), 10), set_qty: value, display: true, - }).then(function (data) { + }).then((data) => { $input.data('update_change', false); var check_value = parseInt($input.val() || 0, 10); if (isNaN(check_value)) { @@ -228,7 +228,7 @@ export const WebsiteSale = publicWidget.Widget.extend(VariantMixin, cartHandlerM wSaleUtils.updateCartNavBar(data); wSaleUtils.showWarning(data.warning); // Propagating the change to the express checkout forms - core.bus.trigger('cart_amount_changed', data.amount, data.minor_amount); + Component.env.bus.trigger('cart_amount_changed', [data.amount, data.minor_amount]); }); }, /** diff --git a/addons/website_sale/static/src/js/website_sale_delivery.js b/addons/website_sale/static/src/js/website_sale_delivery.js index e6dead9063e..fed3b10066b 100644 --- a/addons/website_sale/static/src/js/website_sale_delivery.js +++ b/addons/website_sale/static/src/js/website_sale_delivery.js @@ -1,10 +1,10 @@ /** @odoo-module **/ -import core from "@web/legacy/js/services/core"; import publicWidget from "@web/legacy/js/public/public_widget"; import { _t } from "@web/core/l10n/translation"; import { renderToElement } from "@web/core/utils/render"; import { KeepLast } from "@web/core/utils/concurrency"; +import { Component } from "@odoo/owl"; publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({ selector: '.oe_website_sale', @@ -119,7 +119,7 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({ * @param {float} amount : The new total amount of to be paid */ _updateShippingCost: function(amount) { - core.bus.trigger('update_shipping_cost', amount); + Component.env.bus.trigger('update_shipping_cost', amount); }, /** * Get the rate shipment of a carrier @@ -249,7 +249,7 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({ if (!this._isPayable(status)) { return; } - core.bus.trigger('enableButton'); + Component.env.bus.trigger('enableButton'); }, /** * @private diff --git a/addons/website_slides/__manifest__.py b/addons/website_slides/__manifest__.py index d7d6b72720c..cb45bc0f89f 100644 --- a/addons/website_slides/__manifest__.py +++ b/addons/website_slides/__manifest__.py @@ -180,7 +180,6 @@ Featuring 'web/static/src/legacy/js/libs/bootstrap.js', 'web/static/src/legacy/js/libs/jquery.js', 'website/static/src/libs/zoomodoo/zoomodoo.js', - 'web/static/src/legacy/js/core/bus.js', 'web/static/src/legacy/js/core/class.js', 'web/static/src/legacy/js/core/dialog.js', 'web/static/src/legacy/xml/dialog.xml', @@ -188,7 +187,6 @@ Featuring 'web/static/src/legacy/js/core/mixins.js', 'web/static/src/legacy/js/core/service_mixins.js', 'web/static/src/legacy/js/core/widget.js', - 'web/static/src/legacy/js/services/core.js', 'web/static/src/core/**/*.js', 'web/static/src/env.js', 'web/static/src/libs/pdfjs.js',