Development Book V17:Website Development

Static assets

It is more difficult to manage static assets in Odoo. As you know, it has extensive applications and a code base. The many applications available for Odoo have distinct functions and user interfaces. Hence, compared to other programmes, Odoo's assets are more complex. For example, websites, POS, web clients, or mobile apps have different requirements. Additionally, some elements can be large but are rarely necessary. In this scenario, lazy loading is appropriate (if necessary). It's harmful to load a lot of unnecessary static assets; instead, load them only when necessary. Let's utilise distinct asset batches for every codebase in Odoo to prevent situations like this.

Managing Static Assets

There are a lot of JavaScript and CSS files on modern websites. When the page is uploaded to the browser, these static files send requests to the server. A high volume of requests causes the website to lag. To get around this issue, a lot of websites combine multiple files to provide static assets. There are several tools for managing this type of item, however, Odoo has its approach to handling static assets.

Asset types

Three types of assets exist in Odoo: templates (XML files), style (CSS or SCSS files), and script (JavaScript files).

  1. Script (JavaScript files)

    Three different kinds of JavaScript files are supported by Odoo; each is packed and served to the browser. Plain JavaScript files, native JavaScript modules, and Odoo modules are the three JavaScript file formats that are supported by Odoo. The native JavaScript module system must be used to build any newly created JavaScript files. Odoo modules are a custom module system for these JavaScript files that are processed, minified, and concatenated when not in asset debug mode. The outcome is then stored as an attachment. Typically, the <script> tag is used to load these attachments into static files.

  2. Style (CSS or SCSS files)

    CSS or SCSS files can be used for styling. Style files are handled like JavaScript files and then minified and merged. (debug mode unless debug=asset mode). SCSS files are converted to CSS. The outcome is then stored as an attachment. Typically, the tag is used to load these attachments.

  3. Templates (XML files)

    A static XML file is called a template. Like JavaScript and Elegance files, they are called to be read-only as soon as they are needed and are eventually concatenated in little bits. It calls /web/WebClient/qweb/controller when the browser loads Odoo in order to obtain the template. The first template engine used by Odoo is the QWeb. This XML templating engine is mostly employed for pushing HTML pages and fragments. XML attributes with a t-prefix are used to create template directives. Conditional t-ifs that render components and other attributes directly.

Keep in mind that the browser only makes the requests when the page is loaded. This is so because the source of the page has a checklist that links all of these assets. Next, update the URL with a checksum. This enables you to gradually set cache headers in a secure manner.



Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message