Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[16.0 to 17.0] analytic.project_plan missing error blocks module loading before pre-migration script runs

Aperta
#5,388 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start with the traceback: analytic_data.xml line 14 creates an account.analytic.plan record, which reaches _get_all_plans and _strict_column_name in analytic/models/analytic_plan.py and raises because analytic.project_plan is not yet set. Read the analytic and project pre-migration scripts under openupgrade_scripts/scripts/ to see when that parameter gets created. Done means the 16.0 to 17.0 load gets past analytic_data.xml without the UserError, which likely needs a change in script ordering or a guard in the migration, not a one-line edit. The thread is quiet and unresolved, so confirm with maintainers before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Module

analytic and project

Bug description

While attempting a migration from Odoo 14.0 to 18.0 using OpenUpgrade, the process fails during the phase 16.0 to 17.0, during the module loading phase due to a missing system parameter: analytic.project_plan.

The issue originates from the core analytic module in Odoo 17, where the data file analytic_data.xml defines a record for the account.analytic.plan model. This triggers model logic that expects the analytic.project_plan system parameter to already exist — which it does not at this point.

The migration is being performed using the official OpenUpgrade migration scripts. These scripts correctly create the analytic.project_plan configuration parameter:

However, the error occurs before these scripts are executed. The registry fails to initialize when the system attempts to load the analytic_data.xml file and create the analytic_plan_projects record. During the creation, it calls methods that depend on analytic.project_plan, which is not yet defined in the system parameters at this point in the migration process.

This causes the migration to fail before any of the pre-migration.py scripts are even reached, making it impossible to let OpenUpgrade handle the parameter creation as intended.

Error Logs

2025-09-26 12:03:37,143 1 ERROR ou17 odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/tools/cache.py", line 99, in lookup
    r = d[key]
  File "<decorator-gen-5>", line 2, in __getitem__
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('account.analytic.plan', <function AccountAnalyticPlan.__get_all_plans at 0x7afa1d9cc9d0>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 556, in _tag_root
    f(rec)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 456, in _tag_record
    record = model._load_records([data], self.mode == 'update')
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5088, in _load_records
    records = self._load_records_create([data['values'] for data in to_create])
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4999, in _load_records_create
    return self.create(values)
  File "<decorator-gen-12>", line 2, in create
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 415, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4658, in create
    next(iter(fields)).determine_inverse(batch_recs)
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1398, in determine_inverse
    determine(self.inverse, records)
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 102, in determine
    return needle(*args)
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 125, in _inverse_name
    self._sync_plan_column()
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 262, in _sync_plan_column
    prev = plan._find_plan_column()
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 255, in _find_plan_column
    ('name', 'in', [plan._strict_column_name() for plan in self]),
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 255, in <listcomp>
    ('name', 'in', [plan._strict_column_name() for plan in self]),
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 118, in _strict_column_name
    project_plan, _other_plans = self._get_all_plans()
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 114, in _get_all_plans
    return map(self.browse, self.__get_all_plans())
  File "<decorator-gen-159>", line 2, in __get_all_plans
  File "/opt/odoo/custom/src/odoo/odoo/tools/cache.py", line 104, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 109, in __get_all_plans
    raise UserError(_("A 'Project' plan needs to exist and its id needs to be set as `analytic.project_plan` in the system variables"))
odoo.exceptions.UserError: A 'Project' plan needs to exist and its id needs to be set as `analytic.project_plan` in the system variables

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 114, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 476, in load_modules
    processed_modules += load_marked_modules(env, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 364, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 227, in load_module_graph
    load_data(env, idref, mode, kind='data', package=package)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 71, in load_data
    tools.convert_file(env, package.name, filename, idref, mode, noupdate, kind)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 627, in convert_file
    convert_xml_import(env, module, fp, idref, mode, noupdate)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 693, in convert_xml_import
    obj.parse(doc.getroot())
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 613, in parse
    self._tag_root(de)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 556, in _tag_root
    f(rec)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 569, in _tag_root
    raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing /opt/odoo/auto/addons/analytic/data/analytic_data.xml:14, somewhere inside
<record id="analytic_plan_projects" model="account.analytic.plan">
            <field name="name">Projects</field>
            <field name="default_applicability">optional</field>
        </record>
2025-09-26 12:03:37,146 1 CRITICAL ou17 odoo.service.server: Failed to initialize database `ou17`.
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/tools/cache.py", line 99, in lookup
    r = d[key]
  File "<decorator-gen-5>", line 2, in __getitem__
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('account.analytic.plan', <function AccountAnalyticPlan.__get_all_plans at 0x7afa1d9cc9d0>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 556, in _tag_root
    f(rec)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 456, in _tag_record
    record = model._load_records([data], self.mode == 'update')
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5088, in _load_records
    records = self._load_records_create([data['values'] for data in to_create])
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4999, in _load_records_create
    return self.create(values)
  File "<decorator-gen-12>", line 2, in create
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 415, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4658, in create
    next(iter(fields)).determine_inverse(batch_recs)
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1398, in determine_inverse
    determine(self.inverse, records)
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 102, in determine
    return needle(*args)
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 125, in _inverse_name
    self._sync_plan_column()
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 262, in _sync_plan_column
    prev = plan._find_plan_column()
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 255, in _find_plan_column
    ('name', 'in', [plan._strict_column_name() for plan in self]),
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 255, in <listcomp>
    ('name', 'in', [plan._strict_column_name() for plan in self]),
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 118, in _strict_column_name
    project_plan, _other_plans = self._get_all_plans()
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 114, in _get_all_plans
    return map(self.browse, self.__get_all_plans())
  File "<decorator-gen-159>", line 2, in __get_all_plans
  File "/opt/odoo/custom/src/odoo/odoo/tools/cache.py", line 104, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/opt/odoo/auto/addons/analytic/models/analytic_plan.py", line 109, in __get_all_plans
    raise UserError(_("A 'Project' plan needs to exist and its id needs to be set as `analytic.project_plan` in the system variables"))
odoo.exceptions.UserError: A 'Project' plan needs to exist and its id needs to be set as `analytic.project_plan` in the system variables

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/service/server.py", line 1313, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-16>", line 2, in new
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 114, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 476, in load_modules
    processed_modules += load_marked_modules(env, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 364, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 227, in load_module_graph
    load_data(env, idref, mode, kind='data', package=package)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 71, in load_data
    tools.convert_file(env, package.name, filename, idref, mode, noupdate, kind)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 627, in convert_file
    convert_xml_import(env, module, fp, idref, mode, noupdate)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 693, in convert_xml_import
    obj.parse(doc.getroot())
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 613, in parse
    self._tag_root(de)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 556, in _tag_root
    f(rec)
  File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 569, in _tag_root
    raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing /opt/odoo/auto/addons/analytic/data/analytic_data.xml:14, somewhere inside
<record id="analytic_plan_projects" model="account.analytic.plan">
            <field name="name">Projects</field>
            <field name="default_applicability">optional</field>
        </record>

To Reproduce

Affected versions: 16.0, 17.0

Steps to reproduce the behavior:

  1. launch OpenUpgrade to migrate from 16.0 to 17.0 (or from 14.0 to 18.0 to be in the exact context), on an Odoo with addons analytic and project installed.

Expected behavior
Migration goes smoothly.

Lingua principale
Python
Stelle
995
Fork
837
Merge medio
2g 8h
PR unite (30g)
12

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OCA/OpenUpgrade

Tutte le issue di OCA/OpenUpgrade

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.