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: prevent unnecessary db.commit for contact insert #45300

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

HarryPaulo
Copy link
Contributor

We have ERPNext integrated with another system, when retrieving data from the other system, the following is created:
Customer
Addresses
Contacts
The link between the two systems has been created

When we synchronize, a for loop is performed and the customer, address and contact are inserted, but there may be errors in the process...

When there are errors, a rollback must be performed, but when inserting the contact, ERPNext executes an "after_insert" hook event calling the erpnext.telephony.doctype.call_log.call_log.link_existing_conversations method
thus executing frappe.db.commit()

Two improvements were made:

  1. Only perform frappe.db.commit if there is an impact record returned by the select above.

  2. Created an "ignore_auto_link_call_log" flag to ignore this method when we do not want it to execute, as this commit may break the code.

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Jan 16, 2025
@HarryPaulo HarryPaulo changed the title fix: prevent unnecessary db.commit fix: prevent unnecessary db.commit for contact insert Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant