From 4c4456296523a11a180e5f168f27d7c2f452964c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20=C4=90=E1=BA=A1i=20D=C6=B0=C6=A1ng?= Date: Thu, 23 May 2024 16:41:55 +0700 Subject: [PATCH] [MIG] account_edi*: migration v17 --- docsource/modules160-170.rst | 4 +- .../17.0.1.0/post-migration.py | 30 +++++++++++++ .../17.0.1.0/upgrade_analysis_work.txt | 16 +++++++ .../17.0.1.0/post-migration.py | 15 +++++++ .../17.0.1.0/pre-migration.py | 20 +++++++++ .../17.0.1.0/upgrade_analysis_work.txt | 42 +++++++++++++++++++ 6 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/upgrade_analysis_work.txt create mode 100644 openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/pre-migration.py create mode 100644 openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules160-170.rst b/docsource/modules160-170.rst index 9dc8ddb5c8f6..26055fa7003b 100644 --- a/docsource/modules160-170.rst +++ b/docsource/modules160-170.rst @@ -16,9 +16,9 @@ Module coverage 16.0 -> 17.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | account_edi |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| account_edi_proxy_client | | | +| account_edi_proxy_client |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| account_edi_ubl_cii | | | +| account_edi_ubl_cii |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | account_fleet |Nothing to do |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/post-migration.py b/openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/post-migration.py new file mode 100644 index 000000000000..72740d96f5ad --- /dev/null +++ b/openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/post-migration.py @@ -0,0 +1,30 @@ +# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +def _account_edi_proxy_client_user_fill_edi_mode(env): + demo_state = env["ir.config_parameter"].get_param( + "account_edi_proxy_client.demo", False + ) + if demo_state: + client_users = ( + env["account_edi_proxy_client.user"] + .with_context(active_test=False) + .search([]) + ) + client_users.write( + { + "edi_mode": "prod" + if demo_state in ["prod", False] + else "test" + if demo_state == "test" + else "demo" + } + ) + + +@openupgrade.migrate() +def migrate(env, version): + _account_edi_proxy_client_user_fill_edi_mode(env) diff --git a/openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..fd85449f24ce --- /dev/null +++ b/openupgrade_scripts/scripts/account_edi_proxy_client/17.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,16 @@ +---Models in module 'account_edi_proxy_client'--- +---Fields in module 'account_edi_proxy_client'--- +account_edi_proxy_client / account_edi_proxy_client.user / edi_format_id (many2one) : DEL relation: account.edi.format, required +# NOTHING TO DO + +account_edi_proxy_client / account_edi_proxy_client.user / edi_mode (selection) : NEW selection_keys: ['demo', 'prod', 'test'] +# DONE post-migration: fill value + +account_edi_proxy_client / account_edi_proxy_client.user / proxy_type (selection) : NEW required, selection_keys: [] +# NOTHING TO DO: handle in module that will selection add proxy_type + +---XML records in module 'account_edi_proxy_client'--- +NEW ir.model.constraint: account_edi_proxy_client.constraint_account_edi_proxy_client_user_unique_active_company_proxy +NEW ir.model.constraint: account_edi_proxy_client.constraint_account_edi_proxy_client_user_unique_active_edi_identification +DEL ir.model.constraint: account_edi_proxy_client.constraint_account_edi_proxy_client_user_unique_edi_identification_per_format +# NOTHING TO DO diff --git a/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/post-migration.py b/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/post-migration.py new file mode 100644 index 000000000000..ebe3dec3f3ba --- /dev/null +++ b/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/post-migration.py @@ -0,0 +1,15 @@ +# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +def _res_partner_fill_value(env): + partners = env["res.partner"].with_context(active_test=False).search([]) + partners._compute_ubl_cii_format() + partners._compute_peppol_endpoint() + partners._compute_peppol_eas() + + +@openupgrade.migrate() +def migrate(env, version): + _res_partner_fill_value(env) diff --git a/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/pre-migration.py new file mode 100644 index 000000000000..d828c66d7674 --- /dev/null +++ b/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/pre-migration.py @@ -0,0 +1,20 @@ +# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +def _res_partner_create_column(env): + openupgrade.logged_query( + env.cr, + """ + ALTER TABLE res_partner + ADD COLUMN IF NOT EXISTS peppol_eas VARCHAR, + ADD COLUMN IF NOT EXISTS peppol_endpoint VARCHAR, + ADD COLUMN IF NOT EXISTS ubl_cii_format VARCHAR; + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + _res_partner_create_column(env) diff --git a/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..57903a584b39 --- /dev/null +++ b/openupgrade_scripts/scripts/account_edi_ubl_cii/17.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,42 @@ +---Models in module 'account_edi_ubl_cii'--- +---Fields in module 'account_edi_ubl_cii'--- +account_edi_ubl_cii / account.move / ubl_cii_xml_file (binary) : NEW attachment: True +account_edi_ubl_cii / res.company / invoice_is_ubl_cii (boolean) : NEW hasdefault: default +account_edi_ubl_cii / res.partner / peppol_eas (selection) : NEW selection_keys: ['0002', '0007', '0009', '0037', '0060', '0088', '0096', '0097', '0106', '0130', '0135', '0142', '0151', '0183', '0184', '0188', '0190', '0191', '0192', '0193', '0195', '0196', '0198', '0199', '0200', '0201', '0202', '0204', '0208', '0209', '0210', '0211', '0212', '0213', '0215', '0216', '0221', '0230', '9901', '9910', '9913', '9914', '9915', '9918', '9919', '9920', '9922', '9923', '9924', '9925', '9926', '9927', '9928', '9929', '9930', '9931', '9932', '9933', '9934', '9935', '9936', '9937', '9938', '9939', '9940', '9941', '9942', '9943', '9944', '9945', '9946', '9947', '9948', '9949', '9950', '9951', '9952', '9953', '9955', '9957', '9959'], hasdefault: compute +account_edi_ubl_cii / res.partner / peppol_endpoint (char) : NEW hasdefault: compute +account_edi_ubl_cii / res.partner / ubl_cii_format (selection) : NEW selection_keys: ['facturx', 'nlcius', 'ubl_a_nz', 'ubl_bis3', 'ubl_sg', 'xrechnung'], hasdefault: compute +# DONE pre-migration: create column to avoid compute triggering, post-migration: fill value + +---XML records in module 'account_edi_ubl_cii'--- +DEL account.edi.format: account_edi_ubl_cii.edi_efff_1 +DEL account.edi.format: account_edi_ubl_cii.edi_facturx_1_0_05 +DEL account.edi.format: account_edi_ubl_cii.edi_nlcius_1 +DEL account.edi.format: account_edi_ubl_cii.edi_ubl_2_1 +DEL account.edi.format: account_edi_ubl_cii.ubl_a_nz +DEL account.edi.format: account_edi_ubl_cii.ubl_bis3 +DEL account.edi.format: account_edi_ubl_cii.ubl_de +DEL account.edi.format: account_edi_ubl_cii.ubl_sg +NEW ir.ui.view: account_edi_ubl_cii.account_move_send_form +NEW ir.ui.view: account_edi_ubl_cii.res_config_settings_view_form +NEW ir.ui.view: account_edi_ubl_cii.res_partner_view_search +NEW ir.ui.view: account_edi_ubl_cii.res_partner_view_tree +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_CommonLineType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_CommonType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_CreditNoteLineType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_CreditNoteType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_DebitNote +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_DebitNoteLineType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_DebitNoteType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_DeliveryType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_MonetaryTotalType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_PaymentTermsType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_ResponseType +NEW ir.ui.view: account_edi_ubl_cii.ubl_20_SignatureType +NEW ir.ui.view: account_edi_ubl_cii.ubl_21_CreditNoteLineType +NEW ir.ui.view: account_edi_ubl_cii.ubl_21_CreditNoteType +NEW ir.ui.view: account_edi_ubl_cii.ubl_21_DebitNoteLineType +NEW ir.ui.view: account_edi_ubl_cii.ubl_21_DebitNoteType +NEW ir.ui.view: account_edi_ubl_cii.ubl_21_PaymentTermsType +NEW ir.ui.view: account_edi_ubl_cii.view_partner_property_form +DEL ir.ui.view: account_edi_ubl_cii.ubl_21_InvoiceLineType +# NOTHING TO DO