fix: Remove QI link on cancel wherever same QI name exists

This commit is contained in:
marination 2021-01-08 18:35:49 +05:30
parent c4963bfdb2
commit b7637f49cd

View File

@ -70,9 +70,12 @@ class QualityInspection(Document):
if self.reference_type and self.reference_name:
conditions = ""
if self.batch_no:
if self.batch_no and self.docstatus == 1:
conditions += " and t1.batch_no = '%s'"%(self.batch_no)
if self.docstatus == 2: # if cancel, then remove qi link wherever same name
conditions += " and t1.quality_inspection = '%s'"%(self.name)
frappe.db.sql("""
UPDATE
`tab{child_doc}` t1, `tab{parent_doc}` t2