Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3752 มุมมอง

How to add new Library JS to Odoo 16,  For example, I want to add axios libraries, ui libraries, or other js libraries to odoo, what should I do?
Thanks 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Here are the steps on how to add new JavaScript libraries to Odoo 16:


Place the JS file:


Create a directory named static/src/js within your custom module if it doesn't exist.

Place the library's JavaScript file(s) within this directory.

Register the library in the manifest file:


Open your module's __manifest__.py file.

Under the assets section, add the library's path to the relevant asset list:

Python

'assets': {

    'web.assets_backend': [

        '/path/to/your/module/static/src/js/your_library.js',

        '/path/to/your/module/static/src/js/another_library.js',

   ],

},


Import and use the library in your code:


In your JavaScript files, you can now import and use the library as you would normally do:

JavaScript

import axios from 'axios'; // Example using axios


axios.get('https://api.example.com/data')

    .then(response => {

        // Handle the response

    })

    .catch(error => {

        // Handle errors

    });


Regards

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 24
2123
0
ม.ค. 24
1699
1
ก.ย. 23
3124
2
เม.ย. 23
5300
How to call javascript on button click แก้ไขแล้ว
2
ม.ค. 23
7777