From 01136cabc2a195da0eb7d1ab9109edab80fb5ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Thu, 15 Feb 2024 16:14:44 +0100 Subject: [PATCH 1/2] [OU-ADD] l10n_be_invoice_bba: migration scripts --- .../migrations/13.0.1.2/openupgrade_analysis_work.txt | 11 +++++++++++ .../migrations/13.0.1.2/post-migration.py | 9 +++++++++ odoo/openupgrade/doc/source/modules120-130.rst | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt create mode 100644 addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py diff --git a/addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt new file mode 100644 index 000000000000..3c1a5b2f2d84 --- /dev/null +++ b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt @@ -0,0 +1,11 @@ +---Models in module 'l10n_be_invoice_bba'--- +---Fields in module 'l10n_be_invoice_bba'--- +l10n_be_invoice_bba / account.journal / invoice_reference_model (False): NEW selection_keys: ['be', 'ch', 'euro', 'fi', 'fi_rf', 'no', 'odoo'], mode: modify +# NOTHING TO DO: selection 'be' is added to the existing field on account.journal + +l10n_be_invoice_bba / res.company / l10n_be_structured_comm (selection): DEL selection_keys: ['date', 'partner_ref', 'random'] +# NOTHING TO DO: replaced by the standard OGM-VCS + +---XML records in module 'l10n_be_invoice_bba'--- +DEL ir.ui.view: l10n_be_invoice_bba.res_config_settings_view_form +# NOTHING TO DO: replaced by the standard OGM-VCS diff --git a/addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py new file mode 100644 index 000000000000..4d15c08d7665 --- /dev/null +++ b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py @@ -0,0 +1,9 @@ +# Copyright 2023 Coop IT Easy (https://coopiteasy.be) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data(env.cr, "l10n_be_invoice_bba", "migrations/13.0.1.2/noupdate_changes.xml") diff --git a/odoo/openupgrade/doc/source/modules120-130.rst b/odoo/openupgrade/doc/source/modules120-130.rst index 6269cd9ced50..37958b3f1ed0 100644 --- a/odoo/openupgrade/doc/source/modules120-130.rst +++ b/odoo/openupgrade/doc/source/modules120-130.rst @@ -249,7 +249,7 @@ missing in the new release are marked with |del|. +----------------------------------------------+-------------------------------------------------+ | |del| l10n_be_hr_payroll_fleet | | +----------------------------------------------+-------------------------------------------------+ -|l10n_be_invoice_bba | | +|l10n_be_invoice_bba | Done | +----------------------------------------------+-------------------------------------------------+ |l10n_bo | | +----------------------------------------------+-------------------------------------------------+ From 0a9ba40e288207eb049d94edce34c4feaad1a220 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Mon, 2 Dec 2024 11:57:45 +0100 Subject: [PATCH 2/2] [FIX] fix invoice reference type value fix invoice_reference_type and invoice_reference_model on account.journal when using belgian structured references. --- .../13.0.1.2/openupgrade_analysis_work.txt | 4 +- .../migrations/13.0.1.2/post-migration.py | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt index 3c1a5b2f2d84..d7c79a981f2e 100644 --- a/addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt +++ b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/openupgrade_analysis_work.txt @@ -4,8 +4,8 @@ l10n_be_invoice_bba / account.journal / invoice_reference_model (False) # NOTHING TO DO: selection 'be' is added to the existing field on account.journal l10n_be_invoice_bba / res.company / l10n_be_structured_comm (selection): DEL selection_keys: ['date', 'partner_ref', 'random'] -# NOTHING TO DO: replaced by the standard OGM-VCS +# DONE: post-migration: mapped values to the most sensible available choice ---XML records in module 'l10n_be_invoice_bba'--- DEL ir.ui.view: l10n_be_invoice_bba.res_config_settings_view_form -# NOTHING TO DO: replaced by the standard OGM-VCS +# NOTHING TO DO: this is now handled by the account.view_account_journal_form view diff --git a/addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py index 4d15c08d7665..9d5283f289ab 100644 --- a/addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py +++ b/addons/l10n_be_invoice_bba/migrations/13.0.1.2/post-migration.py @@ -4,6 +4,68 @@ from openupgradelib import openupgrade +def fill_account_journal_invoice_reference_type(env): + # in odoo 12, res.company.invoice_reference_type control the generation of + # the payment reference for invoices. the available choices are: + # + # * "invoice_number" (INV/2024/0001/01), where 1 is the id of the invoice + # * "customer” (CUST/12345), where 12345 is the internal reference of the + # client or its id if it is not defined + # * "structured” (if l10n_be_invoice_bba is installed) + # + # when "structured" is selected, a belgian structured communication is + # generated. its contents depend on the selected algorithm (by + # res.company.l10n_be_structured_comm). 3 algorithms are available: + # + # * "random” (+++838/5211/08712+++) + # * "date” (+++337/2024/00103+++), where 337 is the day number, 2024 is + # the year and the last digits (ignoring the last 2 checksum digits) are + # incremented for each invoice of the same day, thus limit the number of + # invoices per day to 999 + # * "partner_ref” (+++123/4500/00113+++), where 12345 is the internal + # refererence of the client and the last digits (ignoring the last 2 + # checksum digits) are incremented for each invoice for that client, + # thus limiting the overal number of invoices per client) + # + # in odoo 13, invoice_reference_type is defined on account.journal instead + # of on res.company. its available choices are similar ("invoice", + # "partner") but their behavior depend on the value of + # account.journal.invoice_reference_model, which defines the format of the + # reference. the available choices are: + # + # * "odoo", which behaves similarly as in odoo 12 when + # invoice_reference_type is set to "invoice_number" or "customer". + # * "be", which generates a belgian structured communication. + # + # with "be" is selected, although belgian structured communications are + # generated like in odoo 12, none of the previous algorithms are + # available. the algorithms are selected by the invoice_reference_type + # field, and these are the available choices: + # + # * "invoice" (+++000/0000/00101+++), which directly uses the id of the + # invoice. + # * "partner" (+++000/0012/34526+++), which directly uses the reference of + # the client or its id if no reference is defined; the structured + # communication stays the same for all invoices of the same client. + # + # because there is no incrementation with the "partner" choice, it could + # lead to problems if the user expects unique payment references for each + # invoice. therefore, the "invoice" choice (which is the default) is + # forced here, regardless of the previously chosen algorithm. + openupgrade.logged_query( + env.cr, + """ + update account_journal + set + invoice_reference_type = 'invoice', + invoice_reference_model = 'be' + where + invoice_reference_type = 'structured' + """ + ) + + @openupgrade.migrate() def migrate(env, version): + fill_account_journal_invoice_reference_type(env) openupgrade.load_data(env.cr, "l10n_be_invoice_bba", "migrations/13.0.1.2/noupdate_changes.xml")