Skip to content

Commit

Permalink
fix: added validation for quality inspection (frappe#44351)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure authored Nov 26, 2024
1 parent 2ab7ec5 commit 0fd50b5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion erpnext/stock/doctype/quality_inspection/quality_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from frappe import _
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
from frappe.utils import cint, cstr, flt, get_number_format_info
from frappe.utils import cint, cstr, flt, get_link_to_form, get_number_format_info

from erpnext.stock.doctype.quality_inspection_template.quality_inspection_template import (
get_template_details,
Expand Down Expand Up @@ -73,6 +73,27 @@ def validate(self):
if self.readings:
self.inspect_and_set_status()

self.validate_inspection_required()

def validate_inspection_required(self):
if self.reference_type in ["Purchase Receipt", "Purchase Invoice"] and not frappe.get_cached_value(
"Item", self.item_code, "inspection_required_before_purchase"
):
frappe.throw(
_(
"'Inspection Required before Purchase' has disabled for the item {0}, no need to create the QI"
).format(get_link_to_form("Item", self.item_code))
)

if self.reference_type in ["Delivery Note", "Sales Invoice"] and not frappe.get_cached_value(
"Item", self.item_code, "inspection_required_before_delivery"
):
frappe.throw(
_(
"'Inspection Required before Delivery' has disabled for the item {0}, no need to create the QI"
).format(get_link_to_form("Item", self.item_code))
)

def before_submit(self):
self.validate_readings_status_mandatory()

Expand Down

0 comments on commit 0fd50b5

Please sign in to comment.