I tried to add custom css to backend theme using the following code
/theme_custom/__manifest__.py
# -*- coding: utf-8 -*-
{
"name": "Custom Backend Theme V13",
"summary": "Custom Backend Theme V13",
"version": "13.0.0.1",
"category": "Theme/Backend",
"website": "http://www.example.com",
"description": """
Custom Backend theme for Odoo 13.0 community edition.
""",
"author": "me",
"license": "LGPL-3",
"installable": True,
"depends": ["web"],
"data": ["views/assets.xml"],
}
/theme_custom/views/assets.xml
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend" name="Custom Assets for Backend">
<xpath expr="link[last()]" position="after">
<link href="https://fonts.googleapis.com/css?family=Sarabun&display=swap" rel="stylesheet"/>
<link href="/theme_custom/static/src/css/custom.css" type="text/css" rel="stylesheet"/>
</xpath>
</template>
<template id="login_layout" inherit_id="web.login_layout" name="Custom Login Layout">
<xpath expr="." position="inside">
<link href="https://fonts.googleapis.com/css?family=Sarabun&display=swap" rel="stylesheet"/>
<link href="/theme_custom/static/src/css/custom.css" type="text/css" rel="stylesheet"/>
</xpath>
</template>
</odoo>
/theme_custom/static/src/css/custom.css
// some css in this file
After trying to install the custom module, I get the following error
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 713, in parse
self._tag_root(de)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 675, in _tag_root
f(rec)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 653, in _tag_template
return self._tag_record(record)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 491, in _tag_record
model = env[rec_model]
File "/usr/lib/python3/dist-packages/odoo/api.py", line 471, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 175, in __getitem__
return self.models[model_name]
KeyError: 'theme.ir.ui.view'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/http.py", line 664, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 345, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 93, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 338, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 909, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 510, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1323, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1311, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 395, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 382, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-58>", line 2, in button_immediate_install
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 463, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 573, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 85, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 420, in load_modules
loaded_modules, update_module, models_to_check)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 312, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package, report=report)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 68, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 737, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 804, in convert_xml_import
obj.parse(doc.getroot())
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 722, in parse
exc_info[2]
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 13, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 713, in parse
self._tag_root(de)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 675, in _tag_root
f(rec)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 653, in _tag_template
return self._tag_record(record)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 491, in _tag_record
model = env[rec_model]
File "/usr/lib/python3/dist-packages/odoo/api.py", line 471, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 175, in __getitem__
return self.models[model_name]
odoo.tools.convert.ParseError: "theme.ir.ui.view" while parsing /mnt/extra-addons/theme_custom/views/assets.xml:2, near
<odoo>
<template id="login_layout" inherit_id="web.login_layout" name="Custom Login Layout">
<xpath expr="." position="inside">
<link href="https://fonts.googleapis.com/css?family=Sarabun&display=swap" rel="stylesheet"/>
<link href="/theme_custom/static/src/css/custom.css" type="text/css" rel="stylesheet"/>
</xpath>
</template>
</odoo>
I notice that one of the template tag missing in the error logs but not sure what it means or where the error is. Can you help point out what is wrong here?
Odoo version: 13 from the latest official Odoo docker
Can you check this: https://stackoverflow.com/questions/53160591/extending-default-template-odoo-12
I've seen the question in the link. In my case, the custom view inherite from web.assets_backend and web.login_layout so I already put the "web" in "depends" section of manifest file. I also check some other backend theme did the same but it works. Still can't figure it out what goes wrong here. Thanks for the suggestion though.