Skip to content

Commit

Permalink
fix: unset address and contact on trash (frappe#34495)
Browse files Browse the repository at this point in the history
* fix(Customer): unset address and contact on trash

* fix(Supplier): unset address and contact on trash

---------

Co-authored-by: Sagar Sharma <sagarsharma.s312@gmail.com>
  • Loading branch information
barredterra and s-aga-r authored Mar 23, 2023
1 parent 829bc6a commit f7bf1b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
15 changes: 3 additions & 12 deletions erpnext/buying/doctype/supplier/supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,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 @@ -272,18 +272,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

0 comments on commit f7bf1b8

Please sign in to comment.