fix(quality): block Quality Inspection submit without a sample size (backport #59330) (#59331)

This commit is contained in:
Mihir Kandoi
2026-09-23 16:26:56 +05:30
committed by GitHub
parent 242f4219cb
commit 1ead4cebcf
2 changed files with 16 additions and 0 deletions

View File

@@ -155,8 +155,13 @@ class QualityInspection(Document):
)
def before_submit(self):
self.validate_sample_size()
self.validate_readings_status_mandatory()
def validate_sample_size(self):
if flt(self.sample_size) <= 0:
frappe.throw(_("Sample Size must be greater than zero"), title=_("Invalid Sample Size"))
@frappe.whitelist()
def get_item_specification_details(self):
if not self.quality_inspection_template:

View File

@@ -79,6 +79,17 @@ class TestQualityInspection(ERPNextTestSuite):
qa.delete()
dn.delete()
def test_qa_submit_requires_sample_size(self):
dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True)
qa = create_quality_inspection(
reference_type="Delivery Note", reference_name=dn.name, do_not_submit=True
)
for sample_size in (0, -1):
qa.reload()
qa.sample_size = sample_size
self.assertRaisesRegex(frappe.ValidationError, "Sample Size must be greater than zero", qa.submit)
def test_doc_update_published_for_reference_on_submit(self):
"""Submitting a QI publishes doc_update so open reference forms resync their timestamp."""
dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True)