[REF] *: convert last odoo modules to esm

This commit converts odoo modules that haven't been converted with
commit https://github.com/odoo/odoo/pull/117305/commits/e10b45c69e72f09128e49eb46e42834b1ef515d7.
The goal is to deprecate odoo.define in favor of native module and then
simplify boot.js by removing the regexp that finds module dependencies.

task id: 3162300

closes odoo/odoo#118812

Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
Michael (mcm)
2023-04-19 21:58:39 +02:00
parent ebf646b44f
commit 8ec2e8cf80
23 changed files with 95 additions and 133 deletions
+8
View File
@@ -111,6 +111,14 @@
'web/static/lib/bootstrap/scss/_variables.scss',
'mass_mailing/static/src/scss/mass_mailing.ui.scss',
],
'mass_mailing.assets_wysiwyg': [
'mass_mailing/static/src/js/mass_mailing_link_dialog_fix.js',
'mass_mailing/static/src/js/mass_mailing_snippets.js',
'mass_mailing/static/src/snippets/s_masonry_block/options.js',
'mass_mailing/static/src/snippets/s_media_list/options.js',
'mass_mailing/static/src/snippets/s_showcase/options.js',
'mass_mailing/static/src/snippets/s_rating/options.js'
],
'web_editor.assets_wysiwyg': [
'mass_mailing/static/src/js/snippets.editor.js',
'mass_mailing/static/src/js/wysiwyg.js',
@@ -5,7 +5,7 @@ import { _lt } from "@web/core/l10n/translation";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
import { initializeDesignTabCss } from "mass_mailing.design_constants";
import { toInline, getCSSRules } from "web_editor.convertInline";
import { loadBundle, loadJS } from "@web/core/assets";
import { getBundle, loadBundle, loadJS } from "@web/core/assets";
import { qweb } from 'web.core';
import { useService } from "@web/core/utils/hooks";
import { buildQuery } from "web.rpc";
@@ -142,16 +142,8 @@ export class MassMailingHtmlField extends HtmlField {
async startWysiwyg(...args) {
await super.startWysiwyg(...args);
await loadBundle({
jsLibs: [
'/mass_mailing/static/src/js/mass_mailing_link_dialog_fix.js',
'/mass_mailing/static/src/js/mass_mailing_snippets.js',
'/mass_mailing/static/src/snippets/s_masonry_block/options.js',
'/mass_mailing/static/src/snippets/s_media_list/options.js',
'/mass_mailing/static/src/snippets/s_showcase/options.js',
'/mass_mailing/static/src/snippets/s_rating/options.js',
],
});
const assets = await getBundle("mass_mailing.assets_wysiwyg");
await loadBundle(assets);
await this._resetIframe();
}
@@ -1,7 +1,6 @@
odoo.define('mass_mailing.fix.LinkDialog', function (require) {
'use strict';
/** @odoo-module alias=mass_mailing.fix.LinkDialog **/
const LinkDialog = require('wysiwyg.widgets.LinkDialog');
import LinkDialog from "wysiwyg.widgets.LinkDialog";
/**
* Primary and link buttons are "hacked" by mailing themes scss. We thus
@@ -70,4 +69,3 @@ LinkDialog.include({
}
},
});
});
@@ -1,16 +1,15 @@
odoo.define('mass_mailing.snippets.options', function (require) {
"use strict";
/** @odoo-module alias=mass_mailing.snippets.options **/
const options = require('web_editor.snippets.options');
const {ColorpickerWidget} = require('web.Colorpicker');
import options from "web_editor.snippets.options";
import {ColorpickerWidget} from "web.Colorpicker";
const SelectUserValueWidget = options.userValueWidgetsRegistry['we-select'];
const weUtils = require('web_editor.utils');
const {
import weUtils from "web_editor.utils";
import {
CSS_PREFIX, BTN_SIZE_STYLES,
DEFAULT_BUTTON_SIZE, PRIORITY_STYLES, FONT_FAMILIES,
getFontName, normalizeFontFamily, initializeDesignTabCss,
transformFontFamilySelector,
} = require('mass_mailing.design_constants');
} from "mass_mailing.design_constants";
//--------------------------------------------------------------------------
@@ -306,4 +305,3 @@ options.registry.DesignTab = options.Class.extend({
return [...(this.styleSheet.cssRules || this.styleSheet.rules)].find(rule => rule.selectorText === selectorText);
},
});
});
@@ -1,7 +1,6 @@
odoo.define('mass_mailing.masonryOptions', function (require) {
'use strict';
/** @odoo-module alias=mass_mailing.masonryOptions **/
const options = require('web_editor.snippets.options');
import options from "web_editor.snippets.options";
options.registry.MasonryLayout = options.registry.SelectTemplate.extend({
/**
@@ -13,4 +12,3 @@ options.registry.MasonryLayout = options.registry.SelectTemplate.extend({
this.selectTemplateWidgetName = 'masonry_template_opt';
},
});
});
@@ -1,7 +1,6 @@
odoo.define('mass_mailing.s_media_list_options', function (require) {
'use strict';
/** @odoo-module alias=mass_mailing.s_media_list_options **/
const options = require('web_editor.snippets.options');
import options from "web_editor.snippets.options";
options.registry.MediaItemLayout = options.Class.extend({
@@ -47,4 +46,3 @@ options.registry.MediaItemLayout = options.Class.extend({
return this._super(...arguments);
},
});
});
@@ -1,9 +1,8 @@
odoo.define('mass_mailing.s_rating_options', function (require) {
'use strict';
/** @odoo-module alias=mass_mailing.s_rating_options **/
const { ComponentWrapper } = require('web.OwlCompatibility');
const { MediaDialogWrapper } = require('@web_editor/components/media_dialog/media_dialog');
const options = require('web_editor.snippets.options');
import { ComponentWrapper } from "web.OwlCompatibility";
import { MediaDialogWrapper } from "@web_editor/components/media_dialog/media_dialog";
import options from "web_editor.snippets.options";
options.registry.Rating = options.Class.extend({
/**
@@ -142,4 +141,3 @@ options.registry.Rating = options.Class.extend({
$inactiveIcons.removeClass().addClass(faClassInactiveIcons);
},
});
});
@@ -1,7 +1,6 @@
odoo.define('mass_mailing.s_showcase_options', function (require) {
'use strict';
/** @odoo-module alias=mass_mailing.s_showcase_options **/
const options = require('web_editor.snippets.options');
import options from "web_editor.snippets.options";
options.registry.Showcase = options.Class.extend({
/**
@@ -16,4 +15,3 @@ options.registry.Showcase = options.Class.extend({
$title.find('.s_showcase_icon').toggleClass('me-lg-0 ms-lg-3', isLeftCol);
},
});
});
@@ -1,12 +1,11 @@
odoo.define('payment.payment_form_mixin', require => {
'use strict';
/** @odoo-module alias=payment.payment_form_mixin **/
const core = require('web.core');
const Dialog = require('web.Dialog');
import core from "web.core";
import Dialog from "web.Dialog";
const _t = core._t;
return {
export default {
/**
* @override
@@ -45,8 +44,8 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {boolean} showLoadingAnimation - Whether a spinning loader should be shown
* @return {undefined}
*/
_disableButton: (showLoadingAnimation = true) => {
const $submitButton = this.$('button[name="o_payment_submit_button"]');
_disableButton(showLoadingAnimation = true) {
const $submitButton = $('button[name="o_payment_submit_button"]');
const iconClass = $submitButton.data('icon-class');
$submitButton.attr('disabled', true);
if (showLoadingAnimation) {
@@ -211,7 +210,9 @@ odoo.define('payment.payment_form_mixin', require => {
* @return {number} The provider id or the token id or of the payment option linked to the
* radio button.
*/
_getPaymentOptionIdFromRadio: radio => $(radio).data('payment-option-id'),
_getPaymentOptionIdFromRadio(radio) {
return $(radio).data('payment-option-id');
},
/**
* Determine and return the provider of the selected payment option.
@@ -220,7 +221,9 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {HTMLInputElement} radio - The radio button linked to the payment option
* @return {number} The provider of the payment option linked to the radio button.
*/
_getProviderFromRadio: radio => $(radio).data('provider'),
_getProviderFromRadio(radio) {
return $(radio).data('provider');
},
/**
* Remove the error in the provider form.
@@ -228,7 +231,9 @@ odoo.define('payment.payment_form_mixin', require => {
* @private
* @return {jQuery} The removed error
*/
_hideError: () => this.$('div[name="o_payment_error"]').remove(),
_hideError() {
return $('div[name="o_payment_error"]').remove();
},
/**
* Collapse all inline forms.
@@ -236,7 +241,9 @@ odoo.define('payment.payment_form_mixin', require => {
* @private
* @return {undefined}.
*/
_hideInlineForms: () => this.$('[name="o_payment_inline_form"]').addClass('d-none'),
_hideInlineForms() {
return $('[name="o_payment_inline_form"]').addClass('d-none');
},
/**
* Hide the "Save my payment details" label and checkbox, and the submit button.
@@ -322,7 +329,9 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {string} flow - The online payment flow of the selected payment option
* @return {Promise}
*/
_prepareInlineForm: (code, paymentOptionId, flow) => Promise.resolve(),
_prepareInlineForm(code, paymentOptionId, flow) {
return Promise.resolve();
},
/**
* Process the payment.
@@ -376,7 +385,9 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {object} processingValues - The processing values of the transaction
* @return {Promise}
*/
_processDirectPayment: (code, providerId, processingValues) => Promise.resolve(),
_processDirectPayment(code, providerId, processingValues) {
return Promise.resolve();
},
/**
* Redirect the customer by submitting the redirect form included in the processing values.
@@ -390,7 +401,7 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {object} processingValues - The processing values of the transaction
* @return {undefined}
*/
_processRedirectPayment: (code, providerId, processingValues) => {
_processRedirectPayment(code, providerId, processingValues) {
// Append the redirect form to the body
const $redirectForm = $(processingValues.redirect_form_html).attr(
'id', 'o_payment_redirect_form'
@@ -415,7 +426,7 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {object} processingValues - The processing values of the transaction
* @return {undefined}
*/
_processTokenPayment: (provider_code, tokenId, processingValues) => {
_processTokenPayment(provider_code, tokenId, processingValues) {
// The flow is already completed as payments by tokens are immediately processed
window.location = '/payment/status';
},
@@ -470,7 +481,7 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {Event} ev
* @return {undefined}
*/
_onClickLessPaymentIcons: ev => {
_onClickLessPaymentIcons(ev) {
ev.preventDefault();
ev.stopPropagation();
// Hide the extra payment icons, and the "show less" button
@@ -490,7 +501,7 @@ odoo.define('payment.payment_form_mixin', require => {
* @param {Event} ev
* @return {undefined}
*/
_onClickMorePaymentIcons: ev => {
_onClickMorePaymentIcons(ev) {
ev.preventDefault();
ev.stopPropagation();
// Display all the payment methods icons, and the "show less" button
@@ -529,5 +540,3 @@ odoo.define('payment.payment_form_mixin', require => {
},
};
});
@@ -1,5 +1,4 @@
odoo.define('web.autocomplete.extensions', function () {
'use strict';
/** @odoo-module **/
/**
* The jquery autocomplete library extensions and fixes should be done here to
@@ -35,4 +34,3 @@ $.extend(proto, {
.addClass(item.classname);
},
});
});
@@ -1,3 +1,4 @@
/** @odoo-module alias=web.contentdisposition **/
/*
(The MIT License)
@@ -26,8 +27,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/**
* Stripped down to only parsing/decoding.
*/
odoo.define('web.contentdisposition', function () {
'use strict';
/**
* RegExp to match percent encoding escape.
@@ -243,7 +242,6 @@ function ContentDisposition(type, parameters) {
this.parameters = parameters
}
return {
parse: parse,
export default {
parse,
};
});
@@ -1,5 +1,4 @@
odoo.define('web.daterangepicker.extensions', function () {
'use strict';
/** @odoo-module **/
/**
* Don't allow user to select off days(Dates which are out of current calendar).
@@ -20,5 +19,3 @@ daterangepicker.prototype.move = function () {
this.drops = this.container.height() < offset.top ? 'up' : 'down';
moveFunction.apply(this, arguments);
};
});
@@ -1,3 +1,4 @@
/** @odoo-module alias=web.download **/
/*
MIT License
@@ -29,8 +30,7 @@ SOFTWARE.
* @param {String} [filename]
* @param {String} [mimetype]
*/
odoo.define('web.download', function () {
return function download(data, filename, mimetype) {
export default function download(data, filename, mimetype) {
var self = window, // this script is only for browsers anyway...
defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
mimeType = mimetype || defaultMime, payload = data,
@@ -150,4 +150,3 @@ return function download(data, filename, mimetype) {
}
return true;
};
});
+1 -3
View File
@@ -1,5 +1,4 @@
odoo.define('web.jquery.extensions', function () {
'use strict';
/** @odoo-module **/
/**
* The jquery library extensions and fixes should be done here to avoid patching
@@ -228,4 +227,3 @@ $.fn.animate = function (properties, ...rest) {
}
return originalAnimate.call(this, props, ...rest);
};
});
@@ -1,11 +1,10 @@
/** @odoo-module **/
/**
* This file aim to contains the update/fix we have to do on moment.js localizations.
* By using updateLocale and/or defineLocale here, we avoid adding change in the official
* moment.js files, which could lead to conflict when updating the library.
*/
odoo.define('web.moment.extensions', function () {
'use strict';
const locale = moment.locale();
moment.updateLocale('ca', {
preparse: function (string) {
@@ -15,4 +14,3 @@
if(locale !== 'ca'){
moment.locale(locale);
}
});
@@ -1,5 +1,4 @@
odoo.define('web.zoomodoo', function (require) {
'use strict';
/** @odoo-module alias=web.zoomodoo **/
/**
This code has been more that widely inspired by easyZoom library.
@@ -350,4 +349,3 @@ $.fn.zoomOdoo = function (options) {
}
});
};
});
+1
View File
@@ -160,6 +160,7 @@
('prepend', 'website/static/src/scss/secondary_variables.scss'),
],
'web.assets_tests': [
'website/static/tests/tour_utils/**/*',
'website/static/tests/tours/**/*',
'website/static/src/client_actions/website_preview/website_preview_test_mode.js',
],
@@ -1,3 +1,4 @@
/** @odoo-module alias=website_sale.multirange **/
/**
* This code has been more that widely inspired by the multirange library
* which can be found on https://github.com/LeaVerou/multirange.
@@ -5,9 +6,6 @@
* The license file can be found in the same folder as this file.
*/
odoo.define('website_sale.multirange', function () {
'use strict';
/**
* The multirange library will display the two values as one range input with
* two cursors linked by a background. This is to be used with Bootstrap
@@ -62,7 +60,7 @@ odoo.define('website_sale.multirange', function () {
const HTMLInputElement = window.HTMLInputElement;
const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");
class Multirange {
export class Multirange {
constructor(input, options = {}) {
const self = this;
@@ -283,35 +281,14 @@ class Multirange {
}
}
function multirange(input, options) {
export function multirange(input, options) {
if (input.classList.contains('multirange')) {
return;
}
new Multirange(input, options);
}
return {
export default {
Multirange: Multirange,
init: multirange,
};
});
odoo.define('website_sale.multirange.instance', function (require) {
'use strict';
const publicWidget = require('web.public.widget');
const multirange = require('website_sale.multirange');
publicWidget.registry.WebsiteMultirangeInputs = publicWidget.Widget.extend({
selector: 'input[type=range][multiple]:not(.multirange)',
/**
* @override
*/
start() {
return this._super.apply(this, arguments).then(() => {
multirange.init(this.el);
});
},
});
});
@@ -0,0 +1,17 @@
/** @odoo-module alias=website_sale.multirange.instance **/
import publicWidget from "web.public.widget";
import multirange from "website_sale.multirange";
publicWidget.registry.WebsiteMultirangeInputs = publicWidget.Widget.extend({
selector: 'input[type=range][multiple]:not(.multirange)',
/**
* @override
*/
start() {
return this._super.apply(this, arguments).then(() => {
multirange.init(this.el);
});
},
});
@@ -1,3 +1,4 @@
/* @odoo-module */
//
// This file is meant to regroup your javascript code. You can either copy/past
// any code that should be executed on each page loading or write your own
@@ -6,11 +7,8 @@
// world !' message in a popup:
//
/*
odoo.define('website.user_custom_code', function (require) {
'use strict';
var Dialog = require('web.Dialog');
var publicWidget = require('web.public.widget');
import Dialog from 'web.Dialog';
import publicWidget from 'web.public.widget';
publicWidget.registry.HelloWorldPopup = publicWidget.Widget.extend({
selector: '#wrapwrap',
@@ -19,6 +17,5 @@ publicWidget.registry.HelloWorldPopup = publicWidget.Widget.extend({
Dialog.alert(this, "Hello, world!");
return this._super.apply(this, arguments);
},
})
});
*/
@@ -1,7 +1,6 @@
odoo.define('website.tour_focus_blur_snippets_options', function (require) {
'use strict';
/** @odoo-module **/
const options = require('web_editor.snippets.options');
import options from "web_editor.snippets.options";
const FocusBlur = options.Class.extend({
onFocus() {
@@ -15,5 +14,3 @@ const FocusBlur = options.Class.extend({
options.registry.FocusBlurParent = FocusBlur.extend({focusBlurName: 'parent'});
options.registry.FocusBlurChild1 = FocusBlur.extend({focusBlurName: 'child1'});
options.registry.FocusBlurChild2 = FocusBlur.extend({focusBlurName: 'child2'});
});
@@ -1,6 +1,5 @@
/** @odoo-module **/
import { loadJS } from "@web/core/assets";
import { registry } from "@web/core/registry";
const blockIDToData = {
@@ -54,19 +53,9 @@ registry.category("web_tour.tours").add('focus_blur_snippets', {
test: true,
url: '/?enable_editor=1',
steps: [
{
content: 'First load our custom JS options',
trigger: '#oe_snippets.o_loaded',
run: function () {
loadJS('/website/static/tests/tour_utils/focus_blur_snippets_options.js').then(function () {
$('iframe:not(.o_ignore_in_tour)').contents().find('body').addClass('focus_blur_snippets_options_loaded');
});
},
},
{
content: 'Drag the custom block into the page',
trigger: '#snippet_structure .oe_snippet:has(.oe_snippet_body.s_focusblur) .oe_snippet_thumbnail',
extra_trigger: 'iframe body.focus_blur_snippets_options_loaded',
run: 'drag_and_drop iframe #wrap',
},
...clickAndCheck('parent', ['focus parent']),
+1
View File
@@ -73,6 +73,7 @@
'website_sale/static/src/js/website_sale_recently_viewed.js',
'website_sale/static/src/js/website_sale_tracking.js',
'website/static/lib/multirange/multirange_custom.js',
'website/static/lib/multirange/multirange_instance.js',
'website_sale/static/src/js/website_sale_category_link.js',
'website_sale/static/src/xml/website_sale_image_viewer.xml',
'website_sale/static/src/js/components/website_sale_image_viewer.js',