Odoo supports three kinds of JavaScript files: plain scripts (for external libraries), native ES modules (the standard for all new code), and the legacy Odoo custom module system (for older code not yet converted). All JS files are bundled and served to the browser through the asset pipeline defined inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/odoo/documentation/llms.txt
Use this file to discover all available pages before exploring further.
__manifest__.py.
Three Module Flavours
Plain JS
External libraries or low-level scripts with no module system. Use IIFE style to avoid leaking globals. No
import/export.Native ES Modules
All new addon code. Uses standard
import/export syntax. Transpiled by Odoo at serve time into Odoo modules.Odoo Module System
Legacy
odoo.define('name', ['dep'], function(require){}) pattern. Still valid; use for files not yet migrated.Native JavaScript Modules
Writing a Module
Any file under/static/src or /static/tests is automatically transpiled. Use standard ES syntax:
@myaddon/utils/helpers. The naming rule is:
some_addon/static/src/path/to/file.js→@some_addon/path/to/file
Import Paths
Within the same addon, use relative paths:@addon_name/... path:
Opting Out of Transpilation
To prevent a file from being transpiled (e.g., an IIFE library wrapper):Opting In (Outside /static/src)
For files outside the default transpiled directories, add the @odoo-module comment to opt in:
Module Aliases
During migration from the legacy system, create an alias so oldrequire('web.name') calls continue to work:
default export. To alias the entire module namespace:
Transpilation Limitations
The Odoo transpiler is not a full parser. Avoid these patterns:/ are treated as file paths by the heuristic. Do not use / in symbolic module names.
Legacy Odoo Module System
Theodoo.define pattern is still valid for code not yet migrated:
odoo.define takes:
- moduleName — unique string, convention:
addon_name.DescriptiveName - dependencies — array of module name strings required before this module runs
- factory function — receives
require, returns the module’s exported value
Circular dependencies are not supported and will prevent dependent modules from loading. Both the native and legacy systems can coexist within the same addon.
Asset Bundles
JavaScript (and SCSS) files are grouped into asset bundles declared in__manifest__.py. Odoo provides several standard bundles:
| Bundle | Used in |
|---|---|
web.assets_backend | All backend (web client) pages |
web.assets_frontend | Public website pages |
web.assets_common | Shared between backend and frontend |
web.assets_tests | Test tours (loaded in debug=tests mode) |
web.assets_backend_lazy | Loaded on demand in the backend |
Adding Files to a Bundle
In__manifest__.py:
Overriding Bundle Contents
You can prepend, append, or remove entries using special keys:The Patching Mechanism
OWL components and plain objects can be patched (monkey-patched) without modifying source files. Usepatch from @web/core/utils/patch:
Patching Static Methods
When patching a class directly (not.prototype), static properties are affected: