chore: Test case for QI Rejection in Stock Entry
- Use `get_single_value` instead of `get_doc` in validation - Test Case to check impact of stock settings on SE with rejected qi
This commit is contained in:
parent
9ba3fce4fd
commit
f67f13c384
@ -395,7 +395,7 @@ class StockController(AccountsController):
|
|||||||
|
|
||||||
def validate_qi_submission(self, row):
|
def validate_qi_submission(self, row):
|
||||||
"""Check if QI is submitted on row level, during submission"""
|
"""Check if QI is submitted on row level, during submission"""
|
||||||
action = frappe.get_doc('Stock Settings').action_if_quality_inspection_is_not_submitted or "Stop"
|
action = frappe.db.get_single_value("Stock Settings", "action_if_quality_inspection_is_not_submitted")
|
||||||
qa_docstatus = frappe.db.get_value("Quality Inspection", row.quality_inspection, "docstatus")
|
qa_docstatus = frappe.db.get_value("Quality Inspection", row.quality_inspection, "docstatus")
|
||||||
|
|
||||||
if not qa_docstatus == 1:
|
if not qa_docstatus == 1:
|
||||||
@ -408,7 +408,7 @@ class StockController(AccountsController):
|
|||||||
|
|
||||||
def validate_qi_rejection(self, row):
|
def validate_qi_rejection(self, row):
|
||||||
"""Check if QI is rejected on row level, during submission"""
|
"""Check if QI is rejected on row level, during submission"""
|
||||||
action = frappe.get_doc('Stock Settings').action_if_quality_inspection_is_rejected or "Stop"
|
action = frappe.db.get_single_value("Stock Settings", "action_if_quality_inspection_is_rejected")
|
||||||
qa_status = frappe.db.get_value("Quality Inspection", row.quality_inspection, "status")
|
qa_status = frappe.db.get_value("Quality Inspection", row.quality_inspection, "status")
|
||||||
|
|
||||||
if qa_status == "Rejected":
|
if qa_status == "Rejected":
|
||||||
|
@ -14,7 +14,7 @@ from erpnext.controllers.stock_controller import (
|
|||||||
)
|
)
|
||||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||||
from erpnext.stock.doctype.item.test_item import create_item
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
|
||||||
# test_records = frappe.get_test_records('Quality Inspection')
|
# test_records = frappe.get_test_records('Quality Inspection')
|
||||||
|
|
||||||
@ -159,6 +159,47 @@ class TestQualityInspection(unittest.TestCase):
|
|||||||
frappe.delete_doc("Quality Inspection", qi)
|
frappe.delete_doc("Quality Inspection", qi)
|
||||||
dn.delete()
|
dn.delete()
|
||||||
|
|
||||||
|
def test_rejected_qi_validation(self):
|
||||||
|
"""Test if rejected QI blocks Stock Entry as per Stock Settings."""
|
||||||
|
se = make_stock_entry(
|
||||||
|
item_code="_Test Item with QA",
|
||||||
|
target="_Test Warehouse - _TC",
|
||||||
|
qty=1,
|
||||||
|
basic_rate=100,
|
||||||
|
inspection_required=True,
|
||||||
|
do_not_submit=True
|
||||||
|
)
|
||||||
|
|
||||||
|
readings = [
|
||||||
|
{
|
||||||
|
"specification": "Iron Content",
|
||||||
|
"min_value": 0.1,
|
||||||
|
"max_value": 0.9,
|
||||||
|
"reading_1": "0.4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
qa = create_quality_inspection(
|
||||||
|
reference_type="Stock Entry",
|
||||||
|
reference_name=se.name,
|
||||||
|
readings=readings,
|
||||||
|
status="Rejected"
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.db.set_value("Stock Settings", None, "action_if_quality_inspection_is_rejected", "Stop")
|
||||||
|
se.reload()
|
||||||
|
self.assertRaises(QualityInspectionRejectedError, se.submit) # when blocked in Stock settings, block rejected QI
|
||||||
|
|
||||||
|
frappe.db.set_value("Stock Settings", None, "action_if_quality_inspection_is_rejected", "Warn")
|
||||||
|
se.reload()
|
||||||
|
se.submit() # when allowed in Stock settings, allow rejected QI
|
||||||
|
|
||||||
|
# teardown
|
||||||
|
qa.reload()
|
||||||
|
qa.cancel()
|
||||||
|
se.reload()
|
||||||
|
se.cancel()
|
||||||
|
frappe.db.set_value("Stock Settings", None, "action_if_quality_inspection_is_rejected", "Stop")
|
||||||
|
|
||||||
def create_quality_inspection(**args):
|
def create_quality_inspection(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
@ -175,11 +216,10 @@ 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}
|
||||||
else:
|
|
||||||
readings = args.readings
|
|
||||||
|
|
||||||
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:
|
||||||
|
readings = args.readings
|
||||||
|
|
||||||
if isinstance(readings, list):
|
if isinstance(readings, list):
|
||||||
for entry in readings:
|
for entry in readings:
|
||||||
|
@ -45,6 +45,8 @@ def make_stock_entry(**args):
|
|||||||
s.posting_date = args.posting_date
|
s.posting_date = args.posting_date
|
||||||
if args.posting_time:
|
if args.posting_time:
|
||||||
s.posting_time = args.posting_time
|
s.posting_time = args.posting_time
|
||||||
|
if args.inspection_required:
|
||||||
|
s.inspection_required = args.inspection_required
|
||||||
|
|
||||||
# map names
|
# map names
|
||||||
if args.from_warehouse:
|
if args.from_warehouse:
|
||||||
|
@ -290,7 +290,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-21 16:17:42.159829",
|
"modified": "2021-07-10 16:17:42.159829",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Settings",
|
"name": "Stock Settings",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user