mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
Merge pull request #50427 from frappe/mergify/bp/version-15-hotfix/pr-50374
fix: add validation to reject empty readings (backport #50374)
This commit is contained in:
@@ -283,9 +283,11 @@ class QualityInspection(Document):
|
|||||||
|
|
||||||
def min_max_criteria_passed(self, reading):
|
def min_max_criteria_passed(self, reading):
|
||||||
"""Determine whether all readings fall in the acceptable range."""
|
"""Determine whether all readings fall in the acceptable range."""
|
||||||
|
has_reading = False
|
||||||
for i in range(1, 11):
|
for i in range(1, 11):
|
||||||
reading_value = reading.get("reading_" + str(i))
|
reading_value = reading.get("reading_" + str(i))
|
||||||
if reading_value is not None and reading_value.strip():
|
if reading_value is not None and reading_value.strip():
|
||||||
|
has_reading = True
|
||||||
result = (
|
result = (
|
||||||
flt(reading.get("min_value"))
|
flt(reading.get("min_value"))
|
||||||
<= parse_float(reading_value)
|
<= parse_float(reading_value)
|
||||||
@@ -293,7 +295,7 @@ class QualityInspection(Document):
|
|||||||
)
|
)
|
||||||
if not result:
|
if not result:
|
||||||
return False
|
return False
|
||||||
return True
|
return has_reading
|
||||||
|
|
||||||
def set_status_based_on_acceptance_formula(self, reading):
|
def set_status_based_on_acceptance_formula(self, reading):
|
||||||
if not reading.acceptance_formula:
|
if not reading.acceptance_formula:
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ def create_quality_inspection(**args):
|
|||||||
|
|
||||||
if not args.readings:
|
if not args.readings:
|
||||||
create_quality_inspection_parameter("Size")
|
create_quality_inspection_parameter("Size")
|
||||||
readings = {"specification": "Size", "min_value": 0, "max_value": 10}
|
readings = {"specification": "Size", "min_value": 0, "max_value": 10, "reading_1": "5"}
|
||||||
if args.status == "Rejected":
|
if args.status == "Rejected":
|
||||||
readings["reading_1"] = "12" # status is auto set in child on save
|
readings["reading_1"] = "12" # status is auto set in child on save
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user