Skip to content
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

Merged
merged 3 commits into from
Aug 26, 2021

Conversation

brian-pond
Copy link
Contributor

@brian-pond brian-pond commented Aug 3, 2021

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

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`
@brian-pond brian-pond changed the title Fix for Issue #26798 fix: Issue #26798 Customers 'primary_address' not updated automatically. Aug 3, 2021
@brian-pond brian-pond changed the title fix: Issue #26798 Customers 'primary_address' not updated automatically. fix: Customers 'primary_address' not updated automatically (#26798) Aug 3, 2021
Comment on lines 33 to 35
doc_customer = frappe.get_doc("Customer", customer_name[0])
doc_customer.primary_address = address_display
doc_customer.save()
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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!

@stale
Copy link

stale bot commented Aug 24, 2021

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.

@stale stale bot added the inactive label Aug 24, 2021
@stale stale bot removed the inactive label Aug 26, 2021
@nabinhait nabinhait merged commit 1a91977 into frappe:develop Aug 26, 2021
frappe-pr-bot pushed a commit to frappe-pr-bot/erpnext that referenced this pull request Aug 26, 2021
) (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)
nabinhait pushed a commit that referenced this pull request Aug 26, 2021
…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>
asoral pushed a commit to asoral/erpnext that referenced this pull request Nov 12, 2021
) (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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customer 'primary_address' not updated when Address updated
6 participants