19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:28 +01:00
parent ff721d030e
commit 7721452493
1826 changed files with 124775 additions and 274114 deletions

View file

@ -1,5 +0,0 @@
from odoo.addons.account.models.chart_template import update_taxes_from_templates
def migrate(cr, version):
# Add the new tax tags to the credit note repartition lines
update_taxes_from_templates(cr, 'l10n_it.l10n_it_chart_template_generic')

View file

@ -0,0 +1,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, SUPERUSER_ID
def migrate(cr, version):
env = api.Environment(cr, SUPERUSER_ID, {})
for company in env['res.company'].search([('chart_template', '=', 'it')], order="parent_path"):
env['account.chart.template'].try_loading('it', company, force_create=False)

View file

@ -1,5 +0,0 @@
from odoo.addons.account.models.chart_template import update_taxes_from_templates
def migrate(cr, version):
# Change tax tag ve38 from tax repartition lines to base repartition lines
update_taxes_from_templates(cr, 'l10n_it.l10n_it_chart_template_generic')

View file

@ -0,0 +1,76 @@
from odoo import api, SUPERUSER_ID
from odoo.tools import sql
def migrate(cr, version):
env = api.Environment(cr, SUPERUSER_ID, {})
vat_report_id = env.ref('l10n_it.tax_report_vat').id
monthly_vat_report_id = env.ref('l10n_it.tax_monthly_report_vat').id
external_value_cols = [
col
for col in sql.table_columns(env.cr, 'account_report_external_value')
if col not in ['id', 'carryover_origin_report_line_id', 'target_report_expression_id']
]
cr.execute(f"""
SELECT report.id AS report_id,
expression.id AS expression_id,
report_line.code,
external_value.carryover_origin_report_line_id,
{', '.join(f'external_value.{col}' for col in external_value_cols)}
FROM account_report AS report
JOIN account_report_line AS report_line ON report.id = report_line.report_id
JOIN account_report_expression AS expression ON report_line.id = expression.report_line_id
AND expression.engine = 'external'
LEFT JOIN account_report_external_value AS external_value ON expression.id = external_value.target_report_expression_id
WHERE (
report.id = %s
AND external_value.company_id IS NOT NULL
)
OR report.id = %s
ORDER BY expression_id;
""", (vat_report_id, monthly_vat_report_id))
report_info = cr.fetchall()
code2expression_id = {
report_line_code: expression_id
for report_id, expression_id, report_line_code, *_ in report_info
if report_id == monthly_vat_report_id
}
cr.execute("""
SELECT DISTINCT old_report_line.id AS old_origin,
new_report_line.id AS new_origin
FROM account_report_external_value external_value
JOIN account_report_line AS old_report_line ON old_report_line.id = external_value.carryover_origin_report_line_id
AND old_report_line.report_id = %s
JOIN account_report_line AS new_report_line ON new_report_line.code = old_report_line.code
AND new_report_line.report_id = %s;
""", (vat_report_id, monthly_vat_report_id))
carryover_origin_info = cr.fetchall()
old2new_origin = {old_origin: new_origin for old_origin, new_origin in carryover_origin_info}
data_to_insert = [
(code2expression_id[report_line_code], old2new_origin.get(carryover_origin_report_line_id, carryover_origin_report_line_id), *other_external_vals)
for report_id, _, report_line_code, carryover_origin_report_line_id, *other_external_vals in report_info
if report_id == vat_report_id
]
insert_query = f"""
INSERT INTO account_report_external_value (
target_report_expression_id,
carryover_origin_report_line_id,
{', '.join(col for col in external_value_cols)}
)
VALUES (%s, %s, {', '.join('%s' for _ in external_value_cols)})
ON CONFLICT DO NOTHING
"""
if data_to_insert:
cr.executemany(insert_query, data_to_insert)
# Archive the old report
cr.execute("""
UPDATE account_report
SET active = FALSE
WHERE id = %s
""", (vat_report_id,))

View file

@ -0,0 +1,11 @@
def migrate(cr, version):
cr.execute("""
UPDATE account_tax
SET l10n_it_exempt_reason = CASE
WHEN l10n_it_exempt_reason = 'N2' THEN 'N2.2'
WHEN l10n_it_exempt_reason = 'N3' THEN 'N3.6'
WHEN l10n_it_exempt_reason = 'N6' THEN 'N6.9'
END
WHERE l10n_it_exempt_reason IN ('N2', 'N3', 'N6')
""")

View file

@ -0,0 +1,11 @@
def migrate(cr, version):
cr.execute("""
UPDATE account_tax
SET l10n_it_exempt_reason = 'N2.1'
WHERE l10n_it_exempt_reason = 'N3.2'
AND sequence = 185
AND amount = 0.0
AND type_tax_use = 'sale'
AND tax_scope = 'service'
""")

View file

@ -1,24 +0,0 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.account.models.chart_template import update_taxes_from_templates
from odoo import api, SUPERUSER_ID
import psycopg2
import logging
_logger = logging.getLogger(__name__)
def migrate(cr, version):
env = api.Environment(cr, SUPERUSER_ID, {})
account_templates = {account_code: env.ref(f'l10n_it.{account_code}') for account_code in ['2607', '2608']}
companies = env['res.company'].search([('chart_template_id', '=', env.ref('l10n_it.l10n_it_chart_template_generic').id)])
for company in companies:
try:
for account_code, account_template in account_templates.items():
template_vals = [(account_template, company.chart_template_id._get_account_vals(company, account_template, account_code + '00', {}))]
company.chart_template_id._create_records_with_xmlid('account.account', template_vals, company)
_logger.info("Created split payment accounts for company: %s(%s).", company.name, company.id)
except psycopg2.errors.UniqueViolation:
_logger.error("Split payment accounts already exist for company: %s(%s).", company.name, company.id)
update_taxes_from_templates(cr, 'l10n_it.l10n_it_chart_template_generic')