-
Notifications
You must be signed in to change notification settings - Fork 7.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Customers 'primary_address' not updated automatically (#26798) #26799
Conversation
This PR is a fix for GitHub Issue 26798: frappe#26798 TLDR: When an Address is updated, and that Address is a Customer's Primary Address, update the Read Only field `customer.primary_address`
erpnext/accounts/custom/address.py
Outdated
doc_customer = frappe.get_doc("Customer", customer_name[0]) | ||
doc_customer.primary_address = address_display | ||
doc_customer.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use frappe.db.set_value
or frappe.db.update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you believe either of those would be an improvement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PMojito Performance reasons.
get_doc
fetches entire document, its child tables etc. Then save()
goes through all the validations.
db.set_value
bypasses all that and updates in a single SQL query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good feedback; change complete!
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed within a week if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing. |
) (frappe#26799) * Fix for Issue frappe#26798 This PR is a fix for GitHub Issue 26798: frappe#26798 TLDR: When an Address is updated, and that Address is a Customer's Primary Address, update the Read Only field `customer.primary_address` * Update address.py Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> (cherry picked from commit 1a91977)
…26799) (#27178) * Fix for Issue #26798 This PR is a fix for GitHub Issue 26798: #26798 TLDR: When an Address is updated, and that Address is a Customer's Primary Address, update the Read Only field `customer.primary_address` * Update address.py Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> (cherry picked from commit 1a91977) Co-authored-by: Brian Pond <PMojito@users.noreply.github.com>
) (frappe#26799) * Fix for Issue frappe#26798 This PR is a fix for GitHub Issue 26798: frappe#26798 TLDR: When an Address is updated, and that Address is a Customer's Primary Address, update the Read Only field `customer.primary_address` * Update address.py Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
Closes #26798
TLDR: When an Address is updated, and that Address is a Customer's Primary Address, update the Read Only field
customer.primary_address