fix: link deal addresses to customer on auto-creation - #2293
Open
chinmaybhatk wants to merge 1 commit into
Open
Conversation
When a CRM Deal moves to Won and a Customer is auto-created,
addresses linked to the deal via Dynamic Links are not re-linked
to the new Customer. This causes ERPNext to reject the address
in Sales Orders/Invoices with "Billing Address does not belong
to {Customer}".
Added `link_deal_addresses_to_customer()` which runs after customer
creation and adds a Dynamic Link entry for the new Customer on
every address that references the CRM Deal.
Closes frappe#2292
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2293 +/- ##
===========================================
- Coverage 61.62% 61.26% -0.36%
===========================================
Files 141 137 -4
Lines 8315 8205 -110
===========================================
- Hits 5124 5027 -97
+ Misses 3191 3178 -13
🚀 New features to boost your workflow:
|
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
Author
|
@Mergifyio queue |
Contributor
☑️ Command disallowed due to command restrictions in the Mergify configuration.Details
|
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 a CRM Deal moves to "Won" and a Customer is auto-created (via
ERPNext CRM Settings > Create Customer on Status Change), addresses linked to the deal are not re-linked to the new Customer.This causes ERPNext to throw:
when creating Sales Orders or Invoices against the auto-created Customer.
Root Cause
In
create_customer_from_deal(), only the organization's address (viaget_organization_address()) is passed to ERPNext'screate_customerAPI. Addresses linked directly to the CRM Deal via Dynamic Links are completely ignored.After customer creation, those deal-linked addresses still only have:
They're missing:
Steps to Reproduce
Solution
Added
link_deal_addresses_to_customer()which runs immediately after customer creation increate_customer_from_deal(). It:CustomerDynamic Link entry if missingScope
create_addressAPI call; deal-level addresses on remote sites would require ERPNext API changes)Change Summary
erpnext_crm_settings.pylink_deal_addresses_to_customer()functionerpnext_crm_settings.pycreate_customer_from_deal()after customer creationCloses #2292