From 8606fc3492f9a8882dc4d9175c3c29dc489ac33a Mon Sep 17 00:00:00 2001 From: Tomas Date: Sun, 5 Apr 2026 16:03:23 +0200 Subject: [PATCH] initial commit - l10n_sk_partner --- __init__.py | 2 + __manifest__.py | 33 +++++++++++++ hooks.py | 50 +++++++++++++++++++ migrations/19.0.2.0.4/__init__.py | 0 migrations/19.0.2.0.4/post-migrate.py | 71 +++++++++++++++++++++++++++ migrations/19.0.2.0.5/__init__.py | 0 migrations/19.0.2.0.5/post-migrate.py | 46 +++++++++++++++++ migrations/__init__.py | 0 models/__init__.py | 3 ++ models/res_company.py | 13 +++++ models/res_partner.py | 68 +++++++++++++++++++++++++ report/report_layout_sk.xml | 4 ++ security/ir.model.access.csv | 1 + views/res_partner_views.xml | 19 +++++++ 14 files changed, 310 insertions(+) create mode 100644 __init__.py create mode 100644 __manifest__.py create mode 100644 hooks.py create mode 100644 migrations/19.0.2.0.4/__init__.py create mode 100644 migrations/19.0.2.0.4/post-migrate.py create mode 100644 migrations/19.0.2.0.5/__init__.py create mode 100644 migrations/19.0.2.0.5/post-migrate.py create mode 100644 migrations/__init__.py create mode 100644 models/__init__.py create mode 100644 models/res_company.py create mode 100644 models/res_partner.py create mode 100644 report/report_layout_sk.xml create mode 100644 security/ir.model.access.csv create mode 100644 views/res_partner_views.xml diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..a0fdc10 --- /dev/null +++ b/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..23e5e19 --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'Slovakia - Partner DIČ', + 'version': '19.0.2.0.5', + 'category': 'Localization', + 'summary': 'Pridáva DIČ pole na kontakty a opravuje IČO label pre Slovensko', + 'description': """ + Modul pre slovenské daňové identifikátory: + - Pridáva pole DIČ na kontakt + - Opravuje label IČO (namiesto "ID") pre SK partnerov + - Validácia formátov SK čísel (IČO 8 číslic, DIČ 10 číslic, IČ DPH SK+10) + - Automatické vyplnenie DIČ z IČ DPH + - Oprava duplicitného IČ DPH na faktúrach (l10n_sk + natívny blok) + - Podpora importu kontaktov s DIČ + """, + 'author': 'SERIGRAFIKA s.r.o.', + 'website': 'https://serigrafika.sk', + 'license': 'LGPL-3', + 'depends': [ + 'contacts', + 'account', + 'l10n_sk', + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/res_partner_views.xml', + 'report/report_layout_sk.xml', + ], + 'installable': True, + 'auto_install': False, + 'application': False, + 'post_init_hook': 'post_init_hook', +} diff --git a/hooks.py b/hooks.py new file mode 100644 index 0000000..11fb007 --- /dev/null +++ b/hooks.py @@ -0,0 +1,50 @@ +# -*- 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 = """ +
  • + IČO: +
  • +
  • + DIČ: +
  • +
    """ + + new_template_sk = """ +
  • + IČO: +
  • +
  • + DIČ: +
  • +
    """ + + 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}"', + )) diff --git a/migrations/19.0.2.0.4/__init__.py b/migrations/19.0.2.0.4/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/migrations/19.0.2.0.4/post-migrate.py b/migrations/19.0.2.0.4/post-migrate.py new file mode 100644 index 0000000..5510680 --- /dev/null +++ b/migrations/19.0.2.0.4/post-migrate.py @@ -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 = ( + '' + '\n
  • ' + '\n I\u010cO: ' + '\n
  • ' + '\n
  • ' + '\n DI\u010c: ' + '\n
  • ' + '\n
    ' + ) + + 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 = ( + '' + '\n ' + '\n
    ' + '\n I\u010cO: ' + '\n
    ' + '\n
    ' + '\n DI\u010c: ' + '\n
    ' + '\n
    ' + '\n ' + '\n
    ' + '\n I\u010cO: ' + '\n
    ' + '\n
    ' + '\n DI\u010c: ' + '\n
    ' + '\n
    ' + '\n ' + '\n
    ' + '\n I\u010cO: ' + '\n
    ' + '\n
    ' + '\n DI\u010c: ' + '\n
    ' + '\n
    ' + '\n ' + '\n

    ' + '\n Trade registry: ' + '\n

    ' + '\n
    ' + '\n
    ' + ) + + 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)) + diff --git a/migrations/19.0.2.0.5/__init__.py b/migrations/19.0.2.0.5/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/migrations/19.0.2.0.5/post-migrate.py b/migrations/19.0.2.0.5/post-migrate.py new file mode 100644 index 0000000..10d3a39 --- /dev/null +++ b/migrations/19.0.2.0.5/post-migrate.py @@ -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*\n + + + diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv new file mode 100644 index 0000000..97dd8b9 --- /dev/null +++ b/security/ir.model.access.csv @@ -0,0 +1 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink diff --git a/views/res_partner_views.xml b/views/res_partner_views.xml new file mode 100644 index 0000000..f43a4d4 --- /dev/null +++ b/views/res_partner_views.xml @@ -0,0 +1,19 @@ + + + + + res.partner.form.sk + res.partner + + + + + + + + + +