mirror of
https://github.com/bringout/oca-ocb-l10n_europe.git
synced 2026-04-27 14:42:01 +02:00
19.0 vanilla
This commit is contained in:
parent
ff721d030e
commit
7721452493
1826 changed files with 124775 additions and 274114 deletions
|
|
@ -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', '=', 'nl')], order="parent_path"):
|
||||
env['account.chart.template'].try_loading('nl', company, force_create=False)
|
||||
|
|
@ -1,6 +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
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
update_taxes_from_templates(cr, 'l10n_nl.l10nnl_chart_template')
|
||||
|
|
@ -1,26 +1,28 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from psycopg2 import sql
|
||||
from odoo.tools import SQL
|
||||
|
||||
|
||||
def _get_tax_ids_for_xml_id(cr, xml_id):
|
||||
cr.execute(sql.SQL(
|
||||
def _get_tax_ids_for_xml_id(env, xml_id):
|
||||
rows = env.execute_query(SQL(
|
||||
"""
|
||||
SELECT res_id
|
||||
FROM ir_model_data
|
||||
WHERE model = 'account.tax'
|
||||
AND name LIKE '%' || {xml_id}
|
||||
"""
|
||||
).format(xml_id=sql.Literal(xml_id)))
|
||||
|
||||
return [line['res_id'] for line in cr.dictfetchall()]
|
||||
AND name LIKE %s
|
||||
""", f"%{xml_id}"
|
||||
))
|
||||
return [res_id for res_id, in rows]
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
goods_taxes = env['account.tax'].browse(_get_tax_ids_for_xml_id(cr, 'btw_X0_producten'))
|
||||
services_taxes = env['account.tax'].browse(_get_tax_ids_for_xml_id(cr, 'btw_X0_diensten'))
|
||||
goods_tax_ids = [tax_id for xml_id in ['btw_X0_producten', 'btw_X0']
|
||||
for tax_id in _get_tax_ids_for_xml_id(env, xml_id)]
|
||||
|
||||
goods_taxes = env['account.tax'].browse(goods_tax_ids)
|
||||
services_taxes = env['account.tax'].browse(_get_tax_ids_for_xml_id(env, 'btw_X0_diensten'))
|
||||
|
||||
old_3bl_tax_tags = env['account.account.tag']._get_tax_tags('3bl (omzet)', 'nl')
|
||||
old_3b_tax_tags = env['account.account.tag']._get_tax_tags('3b (omzet)', 'nl')
|
||||
|
|
@ -61,48 +63,47 @@ def migrate(cr, version):
|
|||
|
||||
for new_tax_tag_id, tax_ids, old_tax_tag_ids, repartition_line_ids in insert_query_params:
|
||||
insert_query_parts.append(
|
||||
sql.SQL(cr.mogrify("""
|
||||
SELECT tag_aml_rel.account_move_line_id, %s
|
||||
FROM account_account_tag_account_move_line_rel tag_aml_rel
|
||||
JOIN account_move_line_account_tax_rel aml_at_rel ON aml_at_rel.account_move_line_id = tag_aml_rel.account_move_line_id
|
||||
WHERE aml_at_rel.account_tax_id = ANY(%s)
|
||||
AND tag_aml_rel.account_account_tag_id = ANY(%s)
|
||||
""",
|
||||
[new_tax_tag_id, tax_ids, old_tax_tag_ids]
|
||||
).decode())
|
||||
SQL("""
|
||||
SELECT tag_aml_rel.account_move_line_id, %s
|
||||
FROM account_account_tag_account_move_line_rel tag_aml_rel
|
||||
JOIN account_move_line_account_tax_rel aml_at_rel ON aml_at_rel.account_move_line_id = tag_aml_rel.account_move_line_id
|
||||
WHERE aml_at_rel.account_tax_id = ANY(%s)
|
||||
AND tag_aml_rel.account_account_tag_id = ANY(%s)
|
||||
""",
|
||||
new_tax_tag_id, tax_ids, old_tax_tag_ids
|
||||
)
|
||||
)
|
||||
|
||||
if len(old_tax_tag_ids) > 1:
|
||||
cr.execute(
|
||||
cr.execute(SQL(
|
||||
"""
|
||||
DELETE FROM account_account_tag_account_tax_repartition_line_rel tag_aml_rel
|
||||
WHERE tag_aml_rel.account_account_tag_id = %s
|
||||
AND (
|
||||
SELECT COUNT(*)
|
||||
FROM account_account_tag_account_tax_repartition_line_rel sub_tag_aml_rel
|
||||
WHERE sub_tag_aml_rel.account_tax_repartition_line_id = tag_aml_rel.account_tax_repartition_line_id
|
||||
AND sub_tag_aml_rel.account_account_tag_id = %s
|
||||
) >= 1
|
||||
DELETE FROM account_account_tag_account_tax_repartition_line_rel tag_aml_rel
|
||||
WHERE tag_aml_rel.account_account_tag_id = %s
|
||||
AND (
|
||||
SELECT COUNT(*)
|
||||
FROM account_account_tag_account_tax_repartition_line_rel sub_tag_aml_rel
|
||||
WHERE sub_tag_aml_rel.account_tax_repartition_line_id = tag_aml_rel.account_tax_repartition_line_id
|
||||
AND sub_tag_aml_rel.account_account_tag_id = %s
|
||||
) >= 1
|
||||
""",
|
||||
[old_tax_tag_ids[0], old_tax_tag_ids[1]],
|
||||
)
|
||||
old_tax_tag_ids[0], old_tax_tag_ids[1]
|
||||
))
|
||||
|
||||
cr.execute(
|
||||
cr.execute(SQL(
|
||||
"""
|
||||
UPDATE account_account_tag_account_tax_repartition_line_rel
|
||||
SET account_account_tag_id = %s
|
||||
WHERE account_tax_repartition_line_id = ANY(%s)
|
||||
AND account_account_tag_id = ANY(%s)
|
||||
UPDATE account_account_tag_account_tax_repartition_line_rel
|
||||
SET account_account_tag_id = %s
|
||||
WHERE account_tax_repartition_line_id = ANY(%s)
|
||||
AND account_account_tag_id = ANY(%s)
|
||||
""",
|
||||
[new_tax_tag_id, repartition_line_ids, old_tax_tag_ids]
|
||||
)
|
||||
new_tax_tag_id, repartition_line_ids, old_tax_tag_ids
|
||||
))
|
||||
|
||||
cr.execute(
|
||||
sql.SQL("""
|
||||
cr.execute(SQL(
|
||||
"""
|
||||
INSERT INTO account_account_tag_account_move_line_rel (account_move_line_id, account_account_tag_id)
|
||||
{select_statement}
|
||||
%s
|
||||
ON CONFLICT DO NOTHING
|
||||
""").format(
|
||||
select_statement=sql.SQL(" UNION ").join(insert_query_parts),
|
||||
).as_string(cr)
|
||||
)
|
||||
""",
|
||||
SQL(" UNION ").join(insert_query_parts)
|
||||
))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
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', '=', 'nl')], order="parent_path"):
|
||||
env['account.chart.template'].try_loading('nl', company, force_create=False)
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import odoo
|
||||
from odoo.modules.registry import Registry
|
||||
|
||||
def migrate(cr, version):
|
||||
registry = odoo.registry(cr.dbname)
|
||||
registry = Registry(cr.dbname)
|
||||
from odoo.addons.account.models.chart_template import migrate_set_tags_and_taxes_updatable
|
||||
migrate_set_tags_and_taxes_updatable(cr, registry, 'l10n_nl')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue