2

I‌ am trying to load a js file in odoo16 according to the odoo16 document but I can't and it doesn't load my js file despite that it doesn't give any error, I wondered if there is anyone to help me to load a js file in odoo

manifest.py

# -*- coding: utf-8 -*-
{
    ​"name": "Test Module",
    ​'version': '1.0',
    ​'category': 'Theme',
    ​"depends": ['base','website','website_sale_wishlist' ],
    ​'assets': {
    ​   ​'web.assets_frontend': [
    ​   ​   ​'TestModule/static/src/js/content/testfile.js'
    ​   ​ ],
    ​ },
    ​'installable': True,
    ​'auto_install': True
}

My Js FIle

odoo.define('TestModule.testfile', function (require) {
​'use strict';
​var publicWidget = require('web.public.widget');

​publicWidget.registry.testWebsite = publicWidget.Widget.extend({

​   ​selector:'.o_wsale_products_main_row',
​   ​init() {
​   ​   ​console.log('=============');
​   ​},
​ })

});

these codes are for /shop page on the website, when you browes the /shop page in browser it will load it

i wanted to load a js file in odoo16

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • 1
    Hi, just wandering if you ever figured it out? I have run into the same issue and I have tried everything but still can't get those JS to load on the frontend. – Mahdi May 18 '23 at 20:28

2 Answers2

0

you have set the 'category' in your manifest as Website/Website' and it will get fixed

that was fixed because of vivek.c@aktivsoftware.com

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/late-answers/34418141) – Harrison May 22 '23 at 09:25
0

You may have to remove those lines:

odoo.define('TestModule.testfile', function (require) {
​'use strict';

by:

/** @odoo-module **/
LW001
  • 2,452
  • 6
  • 27
  • 36