Keep the current ThirdParty when the source sends an unresolvable customer link - #27
Draft
Pichinov-Jose wants to merge 1 commit into
Draft
Pichinov-Jose wants to merge 1 commit into
Pichinov-Jose wants to merge 1 commit into
Conversation
…tomer link When the remote source cannot resolve an order/invoice customer (the ThirdParty is not linked on its side), the socid write stores the raw unresolved value as null and Commande::update() then fails with "Column 'fk_soc' cannot be null" — blocking the whole object sync. Only overwrite socid when the incoming link resolves to a local ThirdParty; otherwise keep the current one with a warning, and raise an error only when the object has no customer at all (creation case). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
When the remote source cannot resolve an order/invoice customer — its ThirdParty object is not linked/synced on the source side — the connector writes the unresolved value anyway:
setCustomerFields('socid')storesobjects()->id($fieldData)even when that resolves to nothing, sosocidbecomes null and the update then dies with:The whole object sync is blocked, even though the local order already has a perfectly valid customer that nobody asked to change.
Fix
Only overwrite
socidwhen the incoming link actually resolves to a local ThirdParty:ErrLocalFieldMissingerror asdoCustomerDetection().Same protection philosophy as #25: what the source cannot express must not destroy local data.
Reproduced and verified on a live Dolibarr 24.0 + WooCommerce pair: a full-field push with an unlinked customer now completes with a warning and the order keeps its ThirdParty.
🤖 Generated with Claude Code