Files
l10n_sk_partner/hooks.py
T
2026-04-05 16:13:48 +02:00

51 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
def post_init_hook(env):
"""
Opravuje l10n_sk.vat_registry_tax_id_external_layout šablónu:
- Mení 'ID:' na 'IČO:' pre obe jazykové verzie
- Odstraňuje duplicitný IČ DPH riadok
"""
view = env['ir.ui.view'].search([
('key', '=', 'l10n_sk.vat_registry_tax_id_external_layout')
], limit=1)
if not view:
return
new_template_en = """<t t-name="l10n_sk.vat_registry_tax_id_external_layout">
<li t-if="company.company_registry and company.account_fiscal_country_id.code == 'SK'">
IČO: <span t-field="company.company_registry"/>
</li>
<li t-if="company.income_tax_id and company.account_fiscal_country_id.code == 'SK'">
DIČ: <span t-field="company.income_tax_id"/>
</li>
</t>"""
new_template_sk = """<t t-name="l10n_sk.vat_registry_tax_id_external_layout">
<li t-if="company.company_registry and company.account_fiscal_country_id.code == 'SK'">
IČO: <span t-field="company.company_registry"/>
</li>
<li t-if="company.income_tax_id and company.account_fiscal_country_id.code == 'SK'">
DIČ: <span t-field="company.income_tax_id"/>
</li>
</t>"""
env.cr.execute("""
UPDATE ir_ui_view
SET arch_db = jsonb_set(
jsonb_set(
arch_db,
'{en_US}',
%s::jsonb
),
'{sk_SK}',
%s::jsonb
)
WHERE key = 'l10n_sk.vat_registry_tax_id_external_layout'
""", (
f'"{new_template_en}"',
f'"{new_template_sk}"',
))