Merge pull request #46832 from rohitwaghchaure/fixed-support-33851-3

fix: set draft QC in purchase document on creation of qc
This commit is contained in:
rohitwaghchaure
2025-04-01 19:46:36 +05:30
committed by GitHub

View File

@@ -197,8 +197,19 @@ class QualityInspection(Document):
self.quality_inspection_template = template
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):
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):
self.ignore_linked_doctypes = "Serial and Batch Bundle"
@@ -206,15 +217,15 @@ class QualityInspection(Document):
self.update_qc_reference()
def on_trash(self):
self.update_qc_reference()
self.update_qc_reference(remove_reference=True)
def validate_readings_status_mandatory(self):
for reading in self.readings:
if not reading.status:
frappe.throw(_("Row #{0}: Status is mandatory").format(reading.idx))
def update_qc_reference(self):
quality_inspection = self.name if self.docstatus == 1 else ""
def update_qc_reference(self, remove_reference=False):
quality_inspection = self.name if self.docstatus < 2 and not remove_reference else ""
if self.reference_type == "Job Card":
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)
if self.docstatus == 2: # if cancel, then remove qi link wherever same name