Skip to Content
Menú
This question has been flagged
2 Respostes
3462 Vistes

I'm porting an addon I wrote for Odoo17 to v18, and it's going well. 

One issue I'm still unable to figure out is related to the inclusion of a pretty simple JS asset, marked with @odoo-module​: while it works as expected un v17, with v18 I get an odoo.define is not a function​ error in the browser. The reason is that in the latter case it is emitted at the very beginning of web.assets_web.min.js​, before the module_loader.js​ library that defines that function.

In both environments I declared it in the web.assets_backend​ slot of the assets​ entry of the top-level __manifest__.py​ of the addon:

'assets': {'web.assets_backend': ['my_addon/static/src/snippet.js']}


I have read several different addons in the standard community edition source, but could not spot a way to influence the inclusion order, that AFAICT when written that way it should be appended to the bundle...

What am I missing?

Thanks in advance for any hint!

Avatar
Descartar
Best Answer

I my case the js file is nont being loaded for some reason and I am trying to extend the POS component even though the file is correctly loaded:

'assets': {
'web.assets_backend': [
'my_module_name/static/src/js/cash_move_popup_patch.js',
],
'point_of_sale.assets': [
'my_module_name/static/src/js/cash_move_popup_extend.js',
],
},

Here is the file itself:

/** @odoo-module **/
console.log("Patch file loaded")
import { patch } from "@web/core/utils/patch";
import { CashMovePopup } from "@point_of_sale/app/navbar/cash_move_popup/cash_move_popup";

patch(CashMovePopup.prototype, 'custom_cash_move_popup_patch', {
setup() {
console.log("Custom Patch: CashMovePopup has been called.");
// Prevent the original setup method from executing
},
});

The console logs are not showing

Avatar
Descartar

@Radji Mubarak were you able to resolve this issue? I'm having the exact same problem, nothing seems to be executing in my module either. It's like it's completely missing.

Hello everyon i was able to resolve it
'assets': {
'point_of_sale._assets_pos': [
'my_module_name/static/src/js/cash_move_popup_extend.js',
],
},

The magic was in the *_pos*

@Radji, I'm trying to solve a very similar issue with web_editor. I'm doing this:
'assets': {
'web_editor.assets_wysiwyg': [
'web_editor_extensions/static/src/js/wysiwyg.js',
],
},

and also tried this:
'assets': {
'web_editor.backend_assets_wysiwyg': [
'web_editor_extensions/static/src/js/wysiwyg.js',
],
},

And even this:

'assets': {
'web_editor.assets_wysiwyg': [
'web_editor_extensions/static/NOT_A_FOLDER/src/js/wysiwyg.js',
],
},

And I'm not even getting any errors with installing the module. I've tried restarting Odoo on odoo.sh, dropping the staging branch, reinstalling, upgrading, and regenerating the assets. I'm really stumped on this.

Autor Best Answer

For what is worth, I think the issue was related to some kind of cache somewhere: restarting from a clean checkout of the development environment on a different machine did not exhibit the problem, and thus, after spending some time to cleanup whatever seemd like a cache in the original environment, I eventually got it working there too.

Sorry for the noise and thanks for reading.

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de juny 25
559
3
de març 25
1203
1
de febr. 25
1123
1
de maig 25
820
2
de nov. 24
2531