fix: oprava prázdneho IČ DPH riadku na faktúrach SK firiem (v2.0.6)

Migrácia 2.0.5 skryla natívny VAT t-if blok pre SK krajinu, ale t-else
zostal neopravený a renderoval prázdny "IČ DPH:" riadok. Migrácia 2.0.6
mení tento t-else na t-if="forced_vat and country != SK" vo všetkých
7 external_layout šablónach (rôzna indentácia: 28/32/40 medzier).

Pridaný CLAUDE.md s dokumentáciou modulu.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tomas
2026-04-09 00:22:02 +02:00
parent a008aa388d
commit 3e8502178c
4 changed files with 149 additions and 1 deletions
+65
View File
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
"""
Migration script pre l10n_sk_partner 19.0.2.0.6
Opravuje t-else VAT blok vo všetkých external_layout šablónach.
Migrácia 2.0.5 úspešne opravila t-if pre SK (skryla natívny VAT blok),
ale t-else zostal neopravený lebo regex nesprávne matchoval \\n v JSON texte.
Pre SK firmu je teraz t-if vždy False → t-else sa vždy vykreslí → prázdny
"IČ DPH:" riadok na faktúre.
Riešenie: t-else zmeníme na t-if="forced_vat and country != SK" pomocou
replace() s presným JSON textom (\\n a \" sú literálne 2-znakové sekvencie).
Rôzne layouty majú rôznu indentáciu obsahu:
- standard, bold, folder, striped, wave: 28 medzier
- boxed: 32 medzier
- bubble: 40 medzier
"""
# Backslash + double-quote = JSON escaped attribute quote
_Q = '\\"'
# Backslash + n = JSON encoded newline
_NL = '\\n'
def _old(spaces):
return (
'<li t-else=' + _Q + _Q + '>'
+ _NL + ' ' * spaces
+ '<t t-esc=' + _Q + 'company.country_id.vat_label'
)
def _new(spaces):
return (
'<li t-if=' + _Q
+ "forced_vat and company.account_fiscal_country_id.code != 'SK'"
+ _Q + '>'
+ _NL + ' ' * spaces
+ '<t t-esc=' + _Q + 'company.country_id.vat_label'
)
# (key, indentation_spaces)
LAYOUTS = [
('web.external_layout_standard', 28),
('web.external_layout_striped', 28),
('web.external_layout_bold', 28),
('web.external_layout_folder', 28),
('web.external_layout_wave', 28),
('web.external_layout_boxed', 32),
('web.external_layout_bubble', 40),
]
def migrate(cr, version):
for key, spaces in LAYOUTS:
cr.execute("""
UPDATE ir_ui_view
SET arch_db = replace(arch_db::text, %s, %s)::jsonb,
arch_updated = true
WHERE key = %s
""", (_old(spaces), _new(spaces), key))
cr.execute("SELECT * FROM ir_ui_view WHERE key = %s AND arch_updated = true", (key,))
if cr.fetchone():
pass # updated ok