Skip to content

[19.0] project_timeline: UI install fails with lxml ValueError (encoding declaration in module description) #1784

Description

@whotopia

Module

  • Module: project_timeline
  • Version installed: 19.0.1.0.0
  • Odoo version: 19.0 (community, docker)
  • Install method: Apps → search → Install (UI)

Symptom

Clicking Install from the Apps UI raises immediately:

ValueError: Unicode strings with encoding declaration are not supported.
Please use bytes input or XML fragments without declaration.
Full server-side traceback
Traceback (most recent call last):
  File "/odoo/core/odoo/http.py", line 2329, in _serve_db
    return service_model.retrying(serve_func, env=self.env)
  File "/odoo/core/odoo/service/model.py", line 188, in retrying
    result = func()
  File "/odoo/core/odoo/http.py", line 2384, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/odoo/core/odoo/http.py", line 2599, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/odoo/core/odoo/addons/base/models/ir_http.py", line 353, in _dispatch
    result = endpoint(**request.params)
  File "/odoo/core/odoo/http.py", line 838, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/odoo/core/addons/web/controllers/dataset.py", line 38, in call_button
    action = call_kw(request.env[model], method, args, kwargs)
  File "/odoo/core/odoo/service/model.py", line 97, in call_kw
    result = method(recs, *args, **kwargs)
  File "/odoo/core/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
    return method(self, *args, **kwargs)
  File "/odoo/core/odoo/addons/base/models/ir_module.py", line 493, in button_immediate_install
    return self._button_immediate_function(self.env.registry[self._name].button_install)
  File "/odoo/core/odoo/addons/base/models/ir_module.py", line 638, in _button_immediate_function
    registry = modules.registry.Registry.new(self.env.cr.dbname, update_module=True)
  File "/odoo/core/odoo/tools/func.py", line 88, in locked
    return func(inst, *args, **kwargs)
  File "/odoo/core/odoo/orm/registry.py", line 183, in new
    load_modules(...)
  File "/odoo/core/odoo/modules/loading.py", line 464, in load_modules
    load_module_graph(...)
  File "/odoo/core/odoo/modules/loading.py", line 212, in load_module_graph
    module._check()
  File "/odoo/core/odoo/addons/base/models/ir_module.py", line 896, in _check
    if not module.description_html:
  File "/odoo/core/odoo/orm/fields.py", line 1744, in __get__
    self.compute_value(recs)
  File "/odoo/core/odoo/addons/base/models/ir_module.py", line 192, in _get_desc
    module.description_html = _apply_description_images(doc)
  File "/odoo/core/odoo/addons/base/models/ir_module.py", line 178, in _apply_description_images
    html = lxml.html.document_fromstring(doc)
  File "/usr/local/lib/python3.12/site-packages/lxml/html/__init__.py", line 736, in document_fromstring
    value = etree.fromstring(html, parser, **kw)
ValueError: Unicode strings with encoding declaration are not supported.
Please use bytes input or XML fragments without declaration.

Root cause (upstream, not in this module)

The crash is in Odoo core, not in project_timeline. During install, Odoo rebuilds the registry, which triggers the computed field ir.module.module.description_html via _get_desc → inner helper _apply_description_imageslxml.html.document_fromstring(doc).

On Odoo 19.0 (ir_module.py:188-192):

with tools.file_open(path, 'rb') as desc_file:
    doc = desc_file.read().decode()   # → str
    module.description_html = _apply_description_images(doc)

doc is a Python str. It's the contents of static/description/index.html, which for OCA modules generated by oca-gen-addon-readme contains:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

lxml.html.document_fromstring() refuses str inputs that self-declare their encoding — it wants bytes so it can decode itself.

Blast radius

This is not project_timeline-specific. It affects any OCA 19.0 addon whose static/description/index.html was produced by oca-gen-addon-readme. Reporting it here because project_timeline is what I was trying to install; happy to move / cross-file if there's a better home.

Why OCA CI didn't catch it

The migration workflow installs modules via the server CLI, where the compute of description_html may not run (or is called in a context that swallows the error). The failure surfaces reliably only via the UI button_immediate_install path, which forces the registry rebuild that in turn forces the compute.

Related upstream state

  • No open issue on odoo/odoo naming _apply_description_images specifically (I searched).
  • Odoo core has merged ~20 PRs in the last 12 months titled "[FIX] base: prevent error on encoding declaration in ..." for similar-shape bugs elsewhere (view architecture, xml editor, etc.). This code path just hasn't been touched yet.

Possible actions

  1. Patch oca-gen-addon-readme to omit the <meta http-equiv="Content-Type"> line when generating static/description/index.html. Would fix every OCA addon on 19.0 the next time descriptions are regenerated.
  2. Note in the OCA/project README that a workaround is needed until Odoo core is patched.
  3. File coordinated upstream against odoo/odoo (happy to do that too and link back here).

Reproduction

  1. Fresh Odoo 19.0 community instance.
  2. Include OCA/project @ 19.0 in the addons path.
  3. Log in as admin, Apps → search "Project timeline" → click Install.
  4. Crash.

Environment

Thanks to @stferraro for the 19.0 port work (PR #1710) — reporting this here so the next person who trips over it has a hit when they search.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions