From 30ad1e22f26d3b1adc2e3f79455c240017f756a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Mon, 9 Feb 2026 12:10:33 +0100 Subject: [PATCH] [IMP] add correction on l10n_fr_secure_sequence_number field to avoid missing sequence number --- versions/18.0/pre_upgrade.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/versions/18.0/pre_upgrade.sh b/versions/18.0/pre_upgrade.sh index 0465f88..968dc9e 100755 --- a/versions/18.0/pre_upgrade.sh +++ b/versions/18.0/pre_upgrade.sh @@ -121,8 +121,38 @@ EOF echo "Fixing company-dependent columns for Odoo 18..." query_postgres_container "$COMPANY_DEPENDENT_FIX_SQL" ou18 || exit 1 + +# ============================================================================ +# CLEAN: Reset l10n_fr_secure_sequence_number field from table pos_order +# In Odoo 18, several checks are done concerning the pos order, for instance +# that there is no missing number in the order sequence. BUT, if add-on l10n_fr_pos_cert +# has been installer AFTER the creation of some pos orders, then the l10n_fr_secure_sequence_number +# is not filled correctly for all the pos order, and v18 checks fails. +# Solution: reset all the l10n_fr_secure_sequence_number values so that there +# is no missing sequence. +# ============================================================================ +RESET_SECURE_SEQUENCE_NUMBER_SQL=$(cat <<'EOF' +DO $$ +BEGIN + -- res.partner.barcode (base module) + IF EXISTS (SELECT 1 FROM information_schema.columns + WHERE table_name = 'pos_order' AND column_name = 'l10n_fr_secure_sequence_number') THEN + UPDATE pos_order t + SET l10n_fr_secure_sequence_number = r.num + FROM ( + SELECT id, + ROW_NUMBER() OVER (ORDER BY date_order ASC) AS num + FROM pos_order + ) r + WHERE t.id = r.id; + END IF; +END $$; EOF ) +echo "Reset l10n_fr_secure_sequence_number values to avoid missing sequence value for Odoo 18..." +query_postgres_container "$RESET_SECURE_SEQUENCE_NUMBER_SQL" ou18 || exit 1 + + # Execute SQL pre-migration commands PRE_MIGRATE_SQL=$(cat <<'EOF'