Skip to content

Commit 8ec2e8c

Browse files
committed
[REF] *: convert last odoo modules to esm
This commit converts odoo modules that haven't been converted with commit e10b45c. 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 #118812 Signed-off-by: Géry Debongnie <ged@odoo.com>
1 parent ebf646b commit 8ec2e8c

File tree

23 files changed

+95
-133
lines changed

23 files changed

+95
-133
lines changed

addons/mass_mailing/__manifest__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@
111111
'web/static/lib/bootstrap/scss/_variables.scss',
112112
'mass_mailing/static/src/scss/mass_mailing.ui.scss',
113113
],
114+
'mass_mailing.assets_wysiwyg': [
115+
'mass_mailing/static/src/js/mass_mailing_link_dialog_fix.js',
116+
'mass_mailing/static/src/js/mass_mailing_snippets.js',
117+
'mass_mailing/static/src/snippets/s_masonry_block/options.js',
118+
'mass_mailing/static/src/snippets/s_media_list/options.js',
119+
'mass_mailing/static/src/snippets/s_showcase/options.js',
120+
'mass_mailing/static/src/snippets/s_rating/options.js'
121+
],
114122
'web_editor.assets_wysiwyg': [
115123
'mass_mailing/static/src/js/snippets.editor.js',
116124
'mass_mailing/static/src/js/wysiwyg.js',

addons/mass_mailing/static/src/js/mass_mailing_html_field.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { _lt } from "@web/core/l10n/translation";
55
import { standardFieldProps } from "@web/views/fields/standard_field_props";
66
import { initializeDesignTabCss } from "mass_mailing.design_constants";
77
import { toInline, getCSSRules } from "web_editor.convertInline";
8-
import { loadBundle, loadJS } from "@web/core/assets";
8+
import { getBundle, loadBundle, loadJS } from "@web/core/assets";
99
import { qweb } from 'web.core';
1010
import { useService } from "@web/core/utils/hooks";
1111
import { buildQuery } from "web.rpc";
@@ -142,16 +142,8 @@ export class MassMailingHtmlField extends HtmlField {
142142
async startWysiwyg(...args) {
143143
await super.startWysiwyg(...args);
144144

145-
await loadBundle({
146-
jsLibs: [
147-
'/mass_mailing/static/src/js/mass_mailing_link_dialog_fix.js',
148-
'/mass_mailing/static/src/js/mass_mailing_snippets.js',
149-
'/mass_mailing/static/src/snippets/s_masonry_block/options.js',
150-
'/mass_mailing/static/src/snippets/s_media_list/options.js',
151-
'/mass_mailing/static/src/snippets/s_showcase/options.js',
152-
'/mass_mailing/static/src/snippets/s_rating/options.js',
153-
],
154-
});
145+
const assets = await getBundle("mass_mailing.assets_wysiwyg");
146+
await loadBundle(assets);
155147

156148
await this._resetIframe();
157149
}

addons/mass_mailing/static/src/js/mass_mailing_link_dialog_fix.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
odoo.define('mass_mailing.fix.LinkDialog', function (require) {
2-
'use strict';
1+
/** @odoo-module alias=mass_mailing.fix.LinkDialog **/
32

4-
const LinkDialog = require('wysiwyg.widgets.LinkDialog');
3+
import LinkDialog from "wysiwyg.widgets.LinkDialog";
54

65
/**
76
* Primary and link buttons are "hacked" by mailing themes scss. We thus
@@ -70,4 +69,3 @@ LinkDialog.include({
7069
}
7170
},
7271
});
73-
});

addons/mass_mailing/static/src/js/mass_mailing_snippets.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
odoo.define('mass_mailing.snippets.options', function (require) {
2-
"use strict";
1+
/** @odoo-module alias=mass_mailing.snippets.options **/
32

4-
const options = require('web_editor.snippets.options');
5-
const {ColorpickerWidget} = require('web.Colorpicker');
3+
import options from "web_editor.snippets.options";
4+
import {ColorpickerWidget} from "web.Colorpicker";
65
const SelectUserValueWidget = options.userValueWidgetsRegistry['we-select'];
7-
const weUtils = require('web_editor.utils');
8-
const {
6+
import weUtils from "web_editor.utils";
7+
import {
98
CSS_PREFIX, BTN_SIZE_STYLES,
109
DEFAULT_BUTTON_SIZE, PRIORITY_STYLES, FONT_FAMILIES,
1110
getFontName, normalizeFontFamily, initializeDesignTabCss,
1211
transformFontFamilySelector,
13-
} = require('mass_mailing.design_constants');
12+
} from "mass_mailing.design_constants";
1413

1514

1615
//--------------------------------------------------------------------------
@@ -306,4 +305,3 @@ options.registry.DesignTab = options.Class.extend({
306305
return [...(this.styleSheet.cssRules || this.styleSheet.rules)].find(rule => rule.selectorText === selectorText);
307306
},
308307
});
309-
});
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
odoo.define('mass_mailing.masonryOptions', function (require) {
2-
'use strict';
1+
/** @odoo-module alias=mass_mailing.masonryOptions **/
32

4-
const options = require('web_editor.snippets.options');
3+
import options from "web_editor.snippets.options";
54

65
options.registry.MasonryLayout = options.registry.SelectTemplate.extend({
76
/**
@@ -13,4 +12,3 @@ options.registry.MasonryLayout = options.registry.SelectTemplate.extend({
1312
this.selectTemplateWidgetName = 'masonry_template_opt';
1413
},
1514
});
16-
});

addons/mass_mailing/static/src/snippets/s_media_list/options.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
odoo.define('mass_mailing.s_media_list_options', function (require) {
2-
'use strict';
1+
/** @odoo-module alias=mass_mailing.s_media_list_options **/
32

4-
const options = require('web_editor.snippets.options');
3+
import options from "web_editor.snippets.options";
54

65
options.registry.MediaItemLayout = options.Class.extend({
76

@@ -47,4 +46,3 @@ options.registry.MediaItemLayout = options.Class.extend({
4746
return this._super(...arguments);
4847
},
4948
});
50-
});

addons/mass_mailing/static/src/snippets/s_rating/options.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
odoo.define('mass_mailing.s_rating_options', function (require) {
2-
'use strict';
1+
/** @odoo-module alias=mass_mailing.s_rating_options **/
32

4-
const { ComponentWrapper } = require('web.OwlCompatibility');
5-
const { MediaDialogWrapper } = require('@web_editor/components/media_dialog/media_dialog');
6-
const options = require('web_editor.snippets.options');
3+
import { ComponentWrapper } from "web.OwlCompatibility";
4+
import { MediaDialogWrapper } from "@web_editor/components/media_dialog/media_dialog";
5+
import options from "web_editor.snippets.options";
76

87
options.registry.Rating = options.Class.extend({
98
/**
@@ -142,4 +141,3 @@ options.registry.Rating = options.Class.extend({
142141
$inactiveIcons.removeClass().addClass(faClassInactiveIcons);
143142
},
144143
});
145-
});

addons/mass_mailing/static/src/snippets/s_showcase/options.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
odoo.define('mass_mailing.s_showcase_options', function (require) {
2-
'use strict';
1+
/** @odoo-module alias=mass_mailing.s_showcase_options **/
32

4-
const options = require('web_editor.snippets.options');
3+
import options from "web_editor.snippets.options";
54

65
options.registry.Showcase = options.Class.extend({
76
/**
@@ -16,4 +15,3 @@ options.registry.Showcase = options.Class.extend({
1615
$title.find('.s_showcase_icon').toggleClass('me-lg-0 ms-lg-3', isLeftCol);
1716
},
1817
});
19-
});

addons/payment/static/src/js/payment_form_mixin.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
odoo.define('payment.payment_form_mixin', require => {
2-
'use strict';
1+
/** @odoo-module alias=payment.payment_form_mixin **/
32

4-
const core = require('web.core');
5-
const Dialog = require('web.Dialog');
3+
import core from "web.core";
4+
import Dialog from "web.Dialog";
65

76
const _t = core._t;
87

9-
return {
8+
export default {
109

1110
/**
1211
* @override
@@ -45,8 +44,8 @@ odoo.define('payment.payment_form_mixin', require => {
4544
* @param {boolean} showLoadingAnimation - Whether a spinning loader should be shown
4645
* @return {undefined}
4746
*/
48-
_disableButton: (showLoadingAnimation = true) => {
49-
const $submitButton = this.$('button[name="o_payment_submit_button"]');
47+
_disableButton(showLoadingAnimation = true) {
48+
const $submitButton = $('button[name="o_payment_submit_button"]');
5049
const iconClass = $submitButton.data('icon-class');
5150
$submitButton.attr('disabled', true);
5251
if (showLoadingAnimation) {
@@ -211,7 +210,9 @@ odoo.define('payment.payment_form_mixin', require => {
211210
* @return {number} The provider id or the token id or of the payment option linked to the
212211
* radio button.
213212
*/
214-
_getPaymentOptionIdFromRadio: radio => $(radio).data('payment-option-id'),
213+
_getPaymentOptionIdFromRadio(radio) {
214+
return $(radio).data('payment-option-id');
215+
},
215216

216217
/**
217218
* Determine and return the provider of the selected payment option.
@@ -220,23 +221,29 @@ odoo.define('payment.payment_form_mixin', require => {
220221
* @param {HTMLInputElement} radio - The radio button linked to the payment option
221222
* @return {number} The provider of the payment option linked to the radio button.
222223
*/
223-
_getProviderFromRadio: radio => $(radio).data('provider'),
224+
_getProviderFromRadio(radio) {
225+
return $(radio).data('provider');
226+
},
224227

225228
/**
226229
* Remove the error in the provider form.
227230
*
228231
* @private
229232
* @return {jQuery} The removed error
230233
*/
231-
_hideError: () => this.$('div[name="o_payment_error"]').remove(),
234+
_hideError() {
235+
return $('div[name="o_payment_error"]').remove();
236+
},
232237

233238
/**
234239
* Collapse all inline forms.
235240
*
236241
* @private
237242
* @return {undefined}.
238243
*/
239-
_hideInlineForms: () => this.$('[name="o_payment_inline_form"]').addClass('d-none'),
244+
_hideInlineForms() {
245+
return $('[name="o_payment_inline_form"]').addClass('d-none');
246+
},
240247

241248
/**
242249
* Hide the "Save my payment details" label and checkbox, and the submit button.
@@ -322,7 +329,9 @@ odoo.define('payment.payment_form_mixin', require => {
322329
* @param {string} flow - The online payment flow of the selected payment option
323330
* @return {Promise}
324331
*/
325-
_prepareInlineForm: (code, paymentOptionId, flow) => Promise.resolve(),
332+
_prepareInlineForm(code, paymentOptionId, flow) {
333+
return Promise.resolve();
334+
},
326335

327336
/**
328337
* Process the payment.
@@ -376,7 +385,9 @@ odoo.define('payment.payment_form_mixin', require => {
376385
* @param {object} processingValues - The processing values of the transaction
377386
* @return {Promise}
378387
*/
379-
_processDirectPayment: (code, providerId, processingValues) => Promise.resolve(),
388+
_processDirectPayment(code, providerId, processingValues) {
389+
return Promise.resolve();
390+
},
380391

381392
/**
382393
* Redirect the customer by submitting the redirect form included in the processing values.
@@ -390,7 +401,7 @@ odoo.define('payment.payment_form_mixin', require => {
390401
* @param {object} processingValues - The processing values of the transaction
391402
* @return {undefined}
392403
*/
393-
_processRedirectPayment: (code, providerId, processingValues) => {
404+
_processRedirectPayment(code, providerId, processingValues) {
394405
// Append the redirect form to the body
395406
const $redirectForm = $(processingValues.redirect_form_html).attr(
396407
'id', 'o_payment_redirect_form'
@@ -415,7 +426,7 @@ odoo.define('payment.payment_form_mixin', require => {
415426
* @param {object} processingValues - The processing values of the transaction
416427
* @return {undefined}
417428
*/
418-
_processTokenPayment: (provider_code, tokenId, processingValues) => {
429+
_processTokenPayment(provider_code, tokenId, processingValues) {
419430
// The flow is already completed as payments by tokens are immediately processed
420431
window.location = '/payment/status';
421432
},
@@ -470,7 +481,7 @@ odoo.define('payment.payment_form_mixin', require => {
470481
* @param {Event} ev
471482
* @return {undefined}
472483
*/
473-
_onClickLessPaymentIcons: ev => {
484+
_onClickLessPaymentIcons(ev) {
474485
ev.preventDefault();
475486
ev.stopPropagation();
476487
// Hide the extra payment icons, and the "show less" button
@@ -490,7 +501,7 @@ odoo.define('payment.payment_form_mixin', require => {
490501
* @param {Event} ev
491502
* @return {undefined}
492503
*/
493-
_onClickMorePaymentIcons: ev => {
504+
_onClickMorePaymentIcons(ev) {
494505
ev.preventDefault();
495506
ev.stopPropagation();
496507
// Display all the payment methods icons, and the "show less" button
@@ -529,5 +540,3 @@ odoo.define('payment.payment_form_mixin', require => {
529540
},
530541

531542
};
532-
533-
});

addons/web/static/src/legacy/js/libs/autocomplete.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
odoo.define('web.autocomplete.extensions', function () {
2-
'use strict';
1+
/** @odoo-module **/
32

43
/**
54
* The jquery autocomplete library extensions and fixes should be done here to
@@ -35,4 +34,3 @@ $.extend(proto, {
3534
.addClass(item.classname);
3635
},
3736
});
38-
});

0 commit comments

Comments
 (0)