Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
4 Vastaukset
4555 Näkymät

Hi, 


We are working on a custom module for our site on Odoo 16 and its needs to load a JS file to the frontend of the site. So we have added it as an asset on the manifest of the module as per the documentation. However, it is not loading for some reason. Here is our manifest: 

# -*- coding: utf-8 -*-
{
'name': "soloRV_custom_works",

'summary': """
SoloRV Custom Codes
""",

'description': """
Modifications for the SoloRV Project
""",
'author': "Click Theory",
'website': "Redacted",
'category': 'Uncategorized',
'version': '0.1',
'depends': ['base', 'product', 'sale', 'account', 'website', 'website_sale'],
'data': [
'views/templates.xml',
],
'assets': {
'web.assets_frontend': [
'/soloRV_custom_works/static/src/js/custom.js',
'/soloRV_custom_works/static/src/css/custom.css',
],
},
"auto_install": False,
"application": True,
"installable": True,
}

The CSS loads just fine but for some reason the JS is not loading. I have tried everything I could think of without any luck. Any help is appreciated.

Avatar
Hylkää
Tekijä

@Gayarthri A, I have tried removing the / before the path name. Let me try with a wildcard selector here.

Paras vastaus

Try

'assets': {
'web.assets_backend': [
'/soloRV_custom_works/static/src/js/custom.js',
'/soloRV_custom_works/static/src/css/custom.css',
],
},



Avatar
Hylkää
Paras vastaus

Hello Sean,

did you find the solution?
In the same way, I added the JS and CSS files to the manifest, but none of them are added to the website. 
I'm really tired of trying to fix the problem!

'assets': {
​ 'web.assets_frontend': [ 
​ '/energy_website/static/scss/theme.scss',
​​ '/energy_website/static/js/script.js',
​ '/energy_website/static/scss/style.scss',
​ '/energy_website/static/js/myscript.js', ] 
 }
 do you have an idea?

Avatar
Hylkää
Tekijä Paras vastaus

I was able to fix this. The issue wasn't with Odoo, it was with me using window.onload on my script. I am assuming it conflicts with Odoo's lazy load or something in some way. 

Avatar
Hylkää
Paras vastaus

Hi,

Check if the js file path is correct. 

Also Try by removing the "/" in front of the module name.

eg:

'assets': {
   'web.assets_frontend': [

        'soloRV_custom_works/static/src/css/custom.css',
        'soloRV_custom_works/static/src/js/custom.js',
],
},
 
or
 
'assets': {
  'web.assets_frontend': [

     'soloRV_custom_works/static/src/css/**/*,
     'soloRV_custom_works/static/src/js/**/*', 
 ],
},


Regards

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
toukok. 24
1157
2
huhtik. 24
3782
1
huhtik. 24
1305
0
tammik. 24
1039
1
jouluk. 23
1500