Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
615 Prikazi
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="assets_backend_inherit" inherit_id="web.assets_backend" name="Custom Backend Assets">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/css" href="custom_theme/static/src/css/theme.css"/>
</xpath>
</template>
</odoo>

this is my header.xml file

'name': 'Custom Theme Background',
'description': 'Custom website theme',
'category': 'Theme',
'sequence': 10,
'version': '16.0.1',
'depends': ['base_setup', 'base', 'web', 'web_enterprise'],
'data': [
'views/header.xml',
# 'views/footer.xml',
],
'assets': {
'web.assets_backend': [
'/custom_theme/static/src/css/theme.css',
],
},
'installable': True,
'application': False,
'license': 'LGPL-3',
}

help me with this

Avatar
Opusti
Best Answer

In Odoo 16, the assets management system has changed. The old web.assets_backend no longer exists. Instead, Odoo 16 uses:

  • web._assets_backend → For the Community edition
  • web._assets_enterprise → For the Enterprise edition

So, if we try to inherit web.assets_backend, Odoo will throw an error because it does not exist.

Solution:

1. Update the header.xml file

Modify the inherit_id in your XML file:

xml

CopyEdit

<?xml version="1.0" encoding="UTF-8"?> <odoo> <template id="assets_backend_inherit" inherit_id="web._assets_backend" name="Custom Backend Assets"> <xpath expr="." position="inside"> <link rel="stylesheet" type="text/css" href="/custom_theme/static/src/css/theme.css"/> </xpath> </template> </odoo>

If you are using Odoo Enterprise, replace web._assets_backend with web._assets_enterprise.

2. Correctly Define Assets in __manifest__.py

In Odoo 16, assets are defined inside the assets dictionary. Update your __manifest__.py:

python

CopyEdit

'assets': { 'web._assets_backend': [ '/custom_theme/static/src/css/theme.css', ], },

Again, for Enterprise Edition, use web._assets_enterprise.


Restart odoo

Avatar
Opusti
Best Answer

Hi Ahamed,

It seems that you are trying to append the stylesheet.

Do you mind to try the steps below? I took reference from "crm" module.

  1. Remove the xml, don't append through template inheritance.
  2. Inside the manifest.py, remove the slash(/) before "custom_theme"
Avatar
Opusti