From 702fc8c42f7a865e677dfd792c2b6071ef26954b Mon Sep 17 00:00:00 2001 From: Don Kendall Date: Fri, 22 May 2026 10:53:35 -0400 Subject: [PATCH] [OU-FIX] account: drop stale l10n account.report.line xml_ids 19.0 reclassifies many l10n_* tax-report xml_ids from account.report.line to account.report.expression (leaf rows with _base / _tax / _adj suffixes become expressions; hierarchical parents stay as lines). The 18.0 ir_model_data still maps every affected xml_id as account.report.line, so the 19.0 module update crashes with `For external id when trying to create/update a record of model account.report.expression found record of different model account.report.line`. Drop the stale l10n_* lines in pre-migration. The FK account_report_expression.report_line_id ON DELETE CASCADE auto- cleans dependent expressions; the l10n module update reinstalls both under the correct 19.0 model assignment via _load_records(). --- .../scripts/account/19.0.1.4/pre-migration.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openupgrade_scripts/scripts/account/19.0.1.4/pre-migration.py b/openupgrade_scripts/scripts/account/19.0.1.4/pre-migration.py index e2b1dbb77ba2..af0ddac2e340 100644 --- a/openupgrade_scripts/scripts/account/19.0.1.4/pre-migration.py +++ b/openupgrade_scripts/scripts/account/19.0.1.4/pre-migration.py @@ -114,6 +114,23 @@ def account_report(env): ) +def remap_account_report_line_xmlids(env): + """Drop l10n_* xml_ids whose model changed from + account.report.line to account.report.expression in 19.0. Cascade FK + on account_report_expression.report_line_id auto-cleans children; the + l10n module update reinstalls under the correct model. + """ + env.cr.execute( + "DELETE FROM account_report_line WHERE id IN " + "(SELECT res_id FROM ir_model_data " + " WHERE model='account.report.line' AND module LIKE 'l10n_%%')" + ) + env.cr.execute( + "DELETE FROM ir_model_data " + "WHERE model='account.report.line' AND module LIKE 'l10n_%%'" + ) + + def account_report_expression(env): """ Map account.report.expression#date_scope value 'previous_tax_period' to @@ -140,4 +157,5 @@ def migrate(env, version): openupgrade.rename_xmlids(env.cr, _renamed_xmlids) account_journal_invoice_reference_type(env) account_report(env) + remap_account_report_line_xmlids(env) account_report_expression(env)