Initial commit: L10N_Europe packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:52 +02:00
commit 9803722600
2377 changed files with 380711 additions and 0 deletions

View file

@ -0,0 +1,53 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details
from odoo import api, SUPERUSER_ID
def migrate(cr, version):
# The tax report line 68 has been removed as it does not appear in tax report anymore.
# But, it was referenced in the account.sales.report
# So, we update amls of this line only, to make this report consistent.
env = api.Environment(cr, SUPERUSER_ID, {})
country = env['res.country'].search([('code', '=', 'DE')], limit=1)
tags_68 = env['account.account.tag']._get_tax_tags('68', country.id)
tags_60 = env['account.account.tag']._get_tax_tags('60', country.id)
if tags_68.filtered(lambda tag: tag.tax_negate):
cr.execute(
"""
UPDATE account_account_tag_account_move_line_rel
SET account_account_tag_id = %s
WHERE account_account_tag_id IN %s;
""",
[
tags_60.filtered(lambda tag: tag.tax_negate)[0].id,
tuple(tags_68.filtered(lambda tag: tag.tax_negate).ids)
]
)
if tags_68.filtered(lambda tag: not tag.tax_negate):
cr.execute(
"""
UPDATE account_account_tag_account_move_line_rel
SET account_account_tag_id = %s
WHERE account_account_tag_id IN %s;
""",
[
tags_60.filtered(lambda tag: not tag.tax_negate)[0].id,
tuple(tags_68.filtered(lambda tag: not tag.tax_negate).ids)
]
)
cr.execute(
r"""
UPDATE account_move_line
SET tax_audit = REGEXP_REPLACE(tax_audit, '(?<=(^|\s))68:', '60:')
FROM (
SELECT aml.id as aml_id
FROM account_move_line aml
JOIN account_account_tag_account_move_line_rel aml_tag_rel ON aml_tag_rel.account_move_line_id = aml.id
WHERE aml_tag_rel.account_account_tag_id IN %s
) aml
WHERE id = aml.aml_id
""", [tuple(tags_60.ids)]
)

View file

@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
def rename_tag(cr, old_tag, new_tag):
cr.execute(
"""UPDATE ir_model_data
SET name=%s
WHERE module='l10n_de' AND name=%s
""",
(new_tag, old_tag),
)
def migrate(cr, version):
# 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'
"""
)
# 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")
rename_tag(cr, "tag_de_liabilities_bs_D_1", "tag_de_liabilities_bs_C_1")
rename_tag(cr, "tag_de_liabilities_bs_D_2", "tag_de_liabilities_bs_C_2")
rename_tag(cr, "tag_de_liabilities_bs_D_3", "tag_de_liabilities_bs_C_3")
rename_tag(cr, "tag_de_liabilities_bs_D_4", "tag_de_liabilities_bs_C_4")
rename_tag(cr, "tag_de_liabilities_bs_D_5", "tag_de_liabilities_bs_C_5")
rename_tag(cr, "tag_de_liabilities_bs_D_6", "tag_de_liabilities_bs_C_6")
rename_tag(cr, "tag_de_liabilities_bs_D_7", "tag_de_liabilities_bs_C_7")
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")