initial commit - l10n_sk_partner
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Migration script pre l10n_sk_partner 19.0.2.0.4
|
||||
Opravuje l10n_sk šablóny:
|
||||
1. vat_registry_tax_id_external_layout: ID -> IČO, DIČ
|
||||
2. report_invoice_document: IČO, DIČ pre odberateľa na faktúre
|
||||
"""
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
# --- 1. Oprava dodávateľského bloku ---
|
||||
layout_template = (
|
||||
'<t t-name="l10n_sk.vat_registry_tax_id_external_layout">'
|
||||
'\n <li t-if="company.company_registry and company.account_fiscal_country_id.code == \'SK\'">'
|
||||
'\n I\u010cO: <span t-field="company.company_registry"/>'
|
||||
'\n </li>'
|
||||
'\n <li t-if="company.income_tax_id and company.account_fiscal_country_id.code == \'SK\'">'
|
||||
'\n DI\u010c: <span t-field="company.income_tax_id"/>'
|
||||
'\n </li>'
|
||||
'\n </t>'
|
||||
)
|
||||
|
||||
cr.execute("""
|
||||
UPDATE ir_ui_view
|
||||
SET arch_db = jsonb_build_object('en_US', %s, 'sk_SK', %s),
|
||||
arch_updated = true
|
||||
WHERE key = 'l10n_sk.vat_registry_tax_id_external_layout'
|
||||
""", (layout_template, layout_template))
|
||||
|
||||
# --- 2. Oprava odberateľského bloku na faktúre ---
|
||||
invoice_template = (
|
||||
'<data inherit_id="account.report_invoice_document">'
|
||||
'\n <xpath expr="//div[@id=\'partner_vat_address_not_same_as_shipping\']" position="before">'
|
||||
'\n <div t-if="o.partner_id.company_registry and o.company_id.country_code == \'SK\'">'
|
||||
'\n I\u010cO: <span t-field="o.partner_id.company_registry"/>'
|
||||
'\n </div>'
|
||||
'\n <div t-if="o.partner_id.dic and o.company_id.country_code == \'SK\'">'
|
||||
'\n DI\u010c: <span t-field="o.partner_id.dic"/>'
|
||||
'\n </div>'
|
||||
'\n </xpath>'
|
||||
'\n <xpath expr="//div[@id=\'partner_vat_address_same_as_shipping\']" position="before">'
|
||||
'\n <div t-if="o.partner_id.company_registry and o.company_id.country_code == \'SK\'">'
|
||||
'\n I\u010cO: <span t-field="o.partner_id.company_registry"/>'
|
||||
'\n </div>'
|
||||
'\n <div t-if="o.partner_id.dic and o.company_id.country_code == \'SK\'">'
|
||||
'\n DI\u010c: <span t-field="o.partner_id.dic"/>'
|
||||
'\n </div>'
|
||||
'\n </xpath>'
|
||||
'\n <xpath expr="//div[@id=\'partner_vat_no_shipping\']" position="before">'
|
||||
'\n <div t-if="o.partner_id.company_registry and o.company_id.country_code == \'SK\'">'
|
||||
'\n I\u010cO: <span t-field="o.partner_id.company_registry"/>'
|
||||
'\n </div>'
|
||||
'\n <div t-if="o.partner_id.dic and o.company_id.country_code == \'SK\'">'
|
||||
'\n DI\u010c: <span t-field="o.partner_id.dic"/>'
|
||||
'\n </div>'
|
||||
'\n </xpath>'
|
||||
'\n <xpath expr="//div[@name=\'comment\']" position="after">'
|
||||
'\n <p t-if="o.company_id.trade_registry and o.company_id.country_code == \'SK\'" name="trade_registry">'
|
||||
'\n <strong>Trade registry: </strong><t t-out="o.company_id.trade_registry"/>'
|
||||
'\n </p>'
|
||||
'\n </xpath>'
|
||||
'\n </data>'
|
||||
)
|
||||
|
||||
cr.execute("""
|
||||
UPDATE ir_ui_view
|
||||
SET arch_db = jsonb_build_object('en_US', %s, 'sk_SK', %s),
|
||||
arch_updated = true
|
||||
WHERE key = 'l10n_sk.report_invoice_document'
|
||||
""", (invoice_template, invoice_template))
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Migration script pre l10n_sk_partner 19.0.2.0.5
|
||||
Opravuje natívne VAT bloky vo všetkých external_layout šablónach:
|
||||
- Skryje natívny VAT blok pre SK krajinu (l10n_sk ho už zobrazuje)
|
||||
- Opraví t-else blok ktorý zobrazoval US12345671 pre SK
|
||||
"""
|
||||
|
||||
LAYOUT_KEYS = [
|
||||
'web.external_layout_standard',
|
||||
'web.external_layout_striped',
|
||||
'web.external_layout_boxed',
|
||||
'web.external_layout_bold',
|
||||
'web.external_layout_folder',
|
||||
'web.external_layout_wave',
|
||||
'web.external_layout_bubble',
|
||||
]
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
for key in LAYOUT_KEYS:
|
||||
# Skry natívny t-if VAT blok pre SK
|
||||
cr.execute("""
|
||||
UPDATE ir_ui_view
|
||||
SET arch_db = regexp_replace(
|
||||
arch_db::text,
|
||||
't-if="not forced_vat"',
|
||||
't-if="not forced_vat and company.account_fiscal_country_id.code != ''SK''"',
|
||||
'g'
|
||||
)::jsonb,
|
||||
arch_updated = true
|
||||
WHERE key = %s
|
||||
""", (key,))
|
||||
|
||||
# Oprav t-else blok — zmeň na t-if aby sa nezobrazoval pre SK
|
||||
cr.execute("""
|
||||
UPDATE ir_ui_view
|
||||
SET arch_db = regexp_replace(
|
||||
arch_db::text,
|
||||
'li t-else="">\s*\n\s*<t t-esc="company\.country_id\.vat_label',
|
||||
'li t-if="forced_vat and company.account_fiscal_country_id.code != ''SK''">\n <t t-esc="company.country_id.vat_label',
|
||||
'g'
|
||||
)::jsonb,
|
||||
arch_updated = true
|
||||
WHERE key = %s
|
||||
""", (key,))
|
||||
Reference in New Issue
Block a user