diff --git a/addons/l10n_de/migrations/2.0/pre-migrate.py b/addons/l10n_de/migrations/2.0/pre-migrate.py index 7737bf2b4ab..e2e59aca16c 100644 --- a/addons/l10n_de/migrations/2.0/pre-migrate.py +++ b/addons/l10n_de/migrations/2.0/pre-migrate.py @@ -21,6 +21,27 @@ def migrate(cr, version): """ ) + # As some people already upgraded, they will have renamed the C_1 tag to B_1. This doesn't come from the script but from the + # account_account_tags_data.xml. If they try to run this script now in the fix they get the error that B_1 already exists. + # To fix this we can check if it exists or not, and if it does then we don't run the script. This means that the ones + # that upgraded won't have the old tags data transferred to the new tags but they will still be able to have the updated sheet. + cr.execute( + """SELECT 1 FROM ir_model_data + WHERE module='l10n_de' AND name='tag_de_liabilities_bs_B_1' + """) + if cr.rowcount: + # If the script didn't run, we should remove the tags that have been replaced from ir_model_data too so they're + # not deleted by the ORM if they were already used. + cr.execute( + """DELETE FROM ir_model_data + WHERE module='l10n_de' + AND name IN ('tag_de_liabilities_bs_F', 'tag_de_liabilities_bs_D_1', 'tag_de_liabilities_bs_D_2', + 'tag_de_liabilities_bs_D_3', 'tag_de_liabilities_bs_D_4', 'tag_de_liabilities_bs_D_5', + 'tag_de_liabilities_bs_D_6', 'tag_de_liabilities_bs_D_7', 'tag_de_liabilities_bs_D_8') + """ + ) + return + rename_tag(cr, "tag_de_liabilities_bs_C_1", "tag_de_liabilities_bs_B_1") rename_tag(cr, "tag_de_liabilities_bs_C_2", "tag_de_liabilities_bs_B_2") rename_tag(cr, "tag_de_liabilities_bs_C_3", "tag_de_liabilities_bs_B_3")