[FIX] l10n_de/de_reports: fix updating balance sheets
forward ported the commit https://github.com/odoo/odoo/commit/cbefaa6bff5bab6c787d8b9ef4668ba7d9870d55 In odoo#126249 the german balance sheet report was updated and during the 15.2 FW port, some issues needed fixing. The issues and their fixes are: - Deleted tags: As the script didn't run, some tags (like F and all D tags) would be deleted and not renamed. As the tag might already be used as a FK in another table, we remove it from ir_model_data so it's not deleted by the ORM. Also, this means that the tags xml adds the B1 as a new tag which means renaming C1 to B1 will not work in the script due to the unique name constraint, this is handled by checking if B1 exists and if it does we do not run the script. Enterprise PR: odoo/enterprise/pull/45899 closes odoo/odoo#162436 X-original-commit: c019d6f3f5cfe3884ba10fd1aa9357dabe592db8 Signed-off-by: Julien Van Roy (juvr) <juvr@odoo.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user