From 1398c5cd2b185b7bb0cb058d8c1da2c6cc678152 Mon Sep 17 00:00:00 2001
From: "Ali Alfie (alal)" <alal@odoo.com>
Date: Thu, 10 Aug 2023 09:48:27 +0000
Subject: [PATCH] [FIX] l10n_de: remove tag B from ir_model_data

In odoo/odoo/pull/126249 the german balance sheet report was updated and tag tag_de_liabilities_bs_B was removed from account_account_tags_data.xml. This deletes it from ir_model_data so that the ORM doesn't delete this record. This is done so that it doesn't break if another table was already using this tag.

closes odoo/odoo#131530

Signed-off-by: Laurent Smet (las) <las@odoo.com>
---
 addons/l10n_de/migrations/2.0/pre-migrate.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/addons/l10n_de/migrations/2.0/pre-migrate.py b/addons/l10n_de/migrations/2.0/pre-migrate.py
index bd930c80daaa..188619c0e90a 100644
--- a/addons/l10n_de/migrations/2.0/pre-migrate.py
+++ b/addons/l10n_de/migrations/2.0/pre-migrate.py
@@ -25,3 +25,12 @@ def migrate(cr, version):
     rename_tag(cr, "tag_de_liabilities_bs_D_8", "tag_de_liabilities_bs_C_8")
     rename_tag(cr, "tag_de_liabilities_bs_E", "tag_de_liabilities_bs_D")
     rename_tag(cr, "tag_de_liabilities_bs_F", "tag_de_liabilities_bs_E")
+
+    # By deleting tag B from ir_model_data we ensure that the ORM won't try to remove this record.
+    # This is done because the tag might be already used as a FK somewhere else.
+    cr.execute(
+        """DELETE FROM ir_model_data
+           WHERE module='l10n_de'
+           AND name='tag_de_liabilities_bs_B'
+        """
+    )
-- 
GitLab