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>
This commit is contained in:
Raffael Meyer 2023-03-23 07:22:32 +01:00 committed by GitHub
parent 829bc6a51f
commit f7bf1b8a0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 24 deletions

View File

@ -125,18 +125,9 @@ class Supplier(TransactionBase):
def on_trash(self): def on_trash(self):
if self.supplier_primary_contact: if self.supplier_primary_contact:
frappe.db.sql( self.db_set("supplier_primary_contact", None)
""" if self.supplier_primary_address:
UPDATE `tabSupplier` self.db_set("supplier_primary_address", None)
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},
)
delete_contact_and_address("Supplier", self.name) delete_contact_and_address("Supplier", self.name)

View File

@ -272,18 +272,9 @@ class Customer(TransactionBase):
def on_trash(self): def on_trash(self):
if self.customer_primary_contact: if self.customer_primary_contact:
frappe.db.sql( self.db_set("customer_primary_contact", None)
""" if self.customer_primary_address:
UPDATE `tabCustomer` self.db_set("customer_primary_address", None)
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},
)
delete_contact_and_address("Customer", self.name) delete_contact_and_address("Customer", self.name)
if self.lead_name: if self.lead_name: