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: unset address and contact on trash (backport #34495) #34560

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions erpnext/buying/doctype/supplier/supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,9 @@ def create_primary_address(self):

def on_trash(self):
if self.supplier_primary_contact:
frappe.db.sql(
"""
UPDATE `tabSupplier`
SET
supplier_primary_contact=null,
supplier_primary_address=null,
mobile_no=null,
email_id=null,
primary_address=null
WHERE name=%(name)s""",
{"name": self.name},
)
self.db_set("supplier_primary_contact", None)
if self.supplier_primary_address:
self.db_set("supplier_primary_address", None)

delete_contact_and_address("Supplier", self.name)

Expand Down
15 changes: 3 additions & 12 deletions erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,9 @@ def validate_credit_limit_on_change(self):

def on_trash(self):
if self.customer_primary_contact:
frappe.db.sql(
"""
UPDATE `tabCustomer`
SET
customer_primary_contact=null,
customer_primary_address=null,
mobile_no=null,
email_id=null,
primary_address=null
WHERE name=%(name)s""",
{"name": self.name},
)
self.db_set("customer_primary_contact", None)
if self.customer_primary_address:
self.db_set("customer_primary_address", None)

delete_contact_and_address("Customer", self.name)
if self.lead_name:
Expand Down