Odoo 16 Development Book

Operations

Typically, Handling assets is simple: you just need to add some new files to a frequently used bundle like assers_common or assets_backend. But there are other operations available to cover some more specific use cases.

Note that all directives targeting a certain asset file (i.e., before, after, replace and remove) need that file to be declared beforehand, either in manifests higher up in the hierarchy or in ir.asset records with a lower sequence.

1. append

The append operation is used to append one or more files to the end of a bundle. This is the most commonly used operation and allows you to prepend a filename.

'web.assets_common': [
'my_addon/static/src/js/**/*',
],

2. prepend

The prepend operation is used to prepend one or more files to a bundle. This is useful for adding certain files before other files in the bundle.

'web.assets_common': [
('prepend', 'my_addon/static/src/css/bootstrap_overridden.scss'),
],

3. before

The Before operation is used to add one or more files before a specific file. Creating the file at the beginning of the bundle may not be accurate. Can be used to prepend the specified file to the target file.

'web.assets_common': [
('before', 'web/static/src/css/bootstrap_overridden.scss', 'my_addon/static/src/css/bootstrap_overridden.scss'),
],

4. after

After adding one or more files after a specific file. Same as before, but added after the target file.

'web.assets_common': [
('after', 'web/static/src/css/list_view.scss', 'my_addon/static/src/css/list_view.scss'),
],

5. include

Use nested bundles. Include directives may be due to using bundles within other bundles to reduce manifest size.

'web.assets_common': [
('include', 'web._primary_variables'),
],  

6. remove

Sometimes you may want to remove one or more files from a bundle. This can be done with a delete operation.

'web.assets_common': [
(remove, 'web/static/src/js/boot.js'),
],

7. replace

If you want to remove an asset, but add a new version of that asset in the same position. This can be done with the replacement directive.

'web.assets_common': [
('replace', 'web/static/src/js/boot.js', 'my_addon/static/src/js/boot.js'),
],
location

Calicut

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

location

Kochi

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

location

Bangalore

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

Send Us A Message