Repository navigation
[OU-FIX] payment: fill payment.method.provider_id from the old relation - #16
Merged
Merged
Conversation
Co-authored-by: André de Kock <[email protected]>
A method with no provider is kept when it is a primary payment method or still has an xmlid. The dedupe map is dropped first so a retried run can recreate it. Co-authored-by: André de Kock <[email protected]>
column_exists replaces the information_schema probe that selected a nonexistent column named code. Shared 19.0 catalog methods with an xmlid and no provider are removed, xmlid included, so provider-module data can recreate them with provider_id. The warning no longer says those rows were linked to more than one provider. Co-authored-by: André de Kock <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Nov 12, 2026
…) into 20.0-integration-2 Co-authored-by: André de Kock <[email protected]>
Country, currency and image relations are ON DELETE CASCADE, so they kept Discover, JCB and the other provider-less catalog methods from being deleted. Only RESTRICT and NO ACTION foreign keys count as a reference. Dedup still rewrites every foreign key. Co-authored-by: André de Kock <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Nov 12, 2026
…) into 20.0-integration-2 Ignore ON DELETE CASCADE and SET NULL foreign keys when dropping provider-less catalog methods. Co-authored-by: André de Kock <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Two failures while upgrading
paymentto 20.0:from
_deduplicate_provider_code, and after that query is removed:A server retest then left 8 catalog methods NULL: Discover, JCB, Codensa, MyBank, PPS, Venmo, V PAY and WeLend. They have no tokens, transactions or provider links. The only rows that point at them are country, currency and image relations, and those foreign keys are ON DELETE CASCADE.
Root cause
_deduplicate_provider_codeaskedinformation_schemaforSELECT code IS NOT NULL.codeis not a column ofinformation_schema.columns. The probe raises before any dedupe runs.provider_idis required in 20.0. In 19.0 a method is one shared row linked to providers throughpayment_method_payment_provider_rel. In 20.0 each method belongs to one provider. Provider modules create those rows themselves and setprovider_idin the data file, for examplepayment_adyen/payment_method_discoverwithprovider_id=payment.payment_provider_adyen. The corepaymentmodule no longer ships those catalog xmlids. The 19.0 rows are noupdate leftovers with no provider._payment_method_fkstreated every foreign key as a reference. Cascade and set-null constraints do not block the delete: PostgreSQL drops the linking rows or clears the column. The 8 catalog methods stayed NULL only because those cascade relations existed.Decision
Delete a
payment.methodwhoseprovider_idis NULL when no blocking foreign key points at it, and delete itsir.model.datarows with it.A foreign key blocks the delete only when
confdeltypeis notc(ON DELETE CASCADE) orn(ON DELETE SET NULL). RESTRICT and NO ACTION still count.primary_payment_method_idstill counts. Dedup rewrites every foreign key, including cascade, before it deletes a duplicate(provider_id, code).That matches 20.0. A method cannot exist without a provider. Dropping these catalog rows loses no transaction, token, or brand link. The cascade relations disappear with the row. When
payment_adyen(or whichever provider module) loads later in the same upgrade, its data file creates a new method withprovider_idset. If that provider module is not installed, the method should not exist.If a method is still referenced by a blocking foreign key and no single provider can be chosen for it, it stays NULL and the log says so.
The
(provider_id, code)dedupe starts withopenupgrade.column_exists(cr, "payment_method", "code")and returns when the column is absent.Also in this script
payment_method_payment_provider_rel. The lowest provider id keeps the existing row. Further providers get a copy.(provider_id, code)rows keep the lowest id.Verification
ruffandpy_compileare clean. Not merged. The server upgrade is the check for the catalog rows.Upstream
Generic, for OCA
20.0on top of OCA#6068.