fix: set draft QC in purchase document on creation of qc

(cherry picked from commit 2553dea78e)
(cherry picked from commit 54159b9e5e)
This commit is contained in:
Rohit Waghchaure
2025-04-01 13:26:28 +05:30
committed by Mergify
parent 5dd99f896e
commit bf3349a432

View File

@@ -197,8 +197,19 @@ class QualityInspection(Document):
self.quality_inspection_template = template self.quality_inspection_template = template
self.get_item_specification_details() self.get_item_specification_details()
def on_update(self):
if (
frappe.db.get_single_value("Stock Settings", "action_if_quality_inspection_is_not_submitted")
== "Warn"
):
self.update_qc_reference()
def on_submit(self): def on_submit(self):
self.update_qc_reference() if (
frappe.db.get_single_value("Stock Settings", "action_if_quality_inspection_is_not_submitted")
== "Stop"
):
self.update_qc_reference()
def on_cancel(self): def on_cancel(self):
self.ignore_linked_doctypes = "Serial and Batch Bundle" self.ignore_linked_doctypes = "Serial and Batch Bundle"
@@ -206,15 +217,15 @@ class QualityInspection(Document):
self.update_qc_reference() self.update_qc_reference()
def on_trash(self): def on_trash(self):
self.update_qc_reference() self.update_qc_reference(remove_reference=True)
def validate_readings_status_mandatory(self): def validate_readings_status_mandatory(self):
for reading in self.readings: for reading in self.readings:
if not reading.status: if not reading.status:
frappe.throw(_("Row #{0}: Status is mandatory").format(reading.idx)) frappe.throw(_("Row #{0}: Status is mandatory").format(reading.idx))
def update_qc_reference(self): def update_qc_reference(self, remove_reference=False):
quality_inspection = self.name if self.docstatus == 1 else "" quality_inspection = self.name if self.docstatus < 2 and not remove_reference else ""
if self.reference_type == "Job Card": if self.reference_type == "Job Card":
if self.reference_name: if self.reference_name:
@@ -244,7 +255,7 @@ class QualityInspection(Document):
) )
) )
if self.batch_no and self.docstatus == 1: if self.batch_no and self.docstatus < 2:
query = query.where(child_doc.batch_no == self.batch_no) query = query.where(child_doc.batch_no == self.batch_no)
if self.docstatus == 2: # if cancel, then remove qi link wherever same name if self.docstatus == 2: # if cancel, then remove qi link wherever same name