fix: make readings status mandatory in Quality Inspection

This commit is contained in:
Sagar Sharma 2022-10-06 22:36:29 +05:30
parent 39707757a6
commit d7c3b7633a

View File

@ -30,6 +30,9 @@ class QualityInspection(Document):
if self.readings: if self.readings:
self.inspect_and_set_status() self.inspect_and_set_status()
def before_submit(self):
self.validate_readings_status_mandatory()
@frappe.whitelist() @frappe.whitelist()
def get_item_specification_details(self): def get_item_specification_details(self):
if not self.quality_inspection_template: if not self.quality_inspection_template:
@ -65,6 +68,11 @@ class QualityInspection(Document):
def on_cancel(self): def on_cancel(self):
self.update_qc_reference() self.update_qc_reference()
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): def update_qc_reference(self):
quality_inspection = self.name if self.docstatus == 1 else "" quality_inspection = self.name if self.docstatus == 1 else ""