Skip to Content
Menu
This question has been flagged
2 Replies
2848 Views

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
Discard
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
Discard

@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.

Author 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
Discard
Related Posts Replies Views Activity
0
May 25
259
3
Mar 25
828
1
Feb 25
852
1
May 25
563
2
Nov 24
2106