Adding CSS and JavaScript for a website
In this recipe, we'll cover how to add CSS and JavaScript to a website.
Getting ready
We will be using the my_library
module from Chapter 3, Creating Odoo Add-On Modules, for this recipe. You can use the initial module from the https://github.com/PacktPublishing/Odoo-14-Development-Cookbook-Fourth-Edition/tree/master/Chapter14/00_initial_module/my_library GitHub repository. We will add CSS, SCSS, and JavaScript files, which will modify the website. As we are modifying the website, we will need to add website
as a dependency. Modify the manifest
file like this:
... Â Â Â Â 'depends': ['base', 'website'], ...
How to do it...
Override the main website template to inject your code, as follows:
- Add a file called
views/templates.xml
and add an empty view override, as follows (don't forget to list the file in__manifest__.py
):<odoo> Â Â Â Â <template...