fix: unset address and contact on trash (backport #34495) (#34561)

fix: unset address and contact on trash (#34495)

* 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>
(cherry picked from commit f7bf1b8a0c)

Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2023-03-23 12:58:54 +05:30
committed by GitHub
parent ad5eb6da4e
commit 7f83d15bda
2 changed files with 6 additions and 24 deletions

View File

@@ -128,18 +128,9 @@ class Supplier(TransactionBase):
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)

View File

@@ -275,18 +275,9 @@ class Customer(TransactionBase):
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: