fix: Create QI Parameters (links) in test cases
This commit is contained in:
parent
a69e81a151
commit
7877d5a7c2
@ -6,6 +6,7 @@ import unittest
|
|||||||
|
|
||||||
from erpnext.stock.doctype.item.test_item import set_item_variant_settings
|
from erpnext.stock.doctype.item.test_item import set_item_variant_settings
|
||||||
from erpnext.controllers.item_variant import copy_attributes_to_variant, make_variant_item_code
|
from erpnext.controllers.item_variant import copy_attributes_to_variant, make_variant_item_code
|
||||||
|
from erpnext.stock.doctype.quality_inspection.test_quality_inspection import create_quality_inspection_parameter
|
||||||
|
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
@ -56,6 +57,8 @@ def make_quality_inspection_template():
|
|||||||
|
|
||||||
qc = frappe.new_doc("Quality Inspection Template")
|
qc = frappe.new_doc("Quality Inspection Template")
|
||||||
qc.quality_inspection_template_name = qc_template
|
qc.quality_inspection_template_name = qc_template
|
||||||
|
|
||||||
|
create_quality_inspection_parameter("Moisture")
|
||||||
qc.append('item_quality_inspection_parameter', {
|
qc.append('item_quality_inspection_parameter', {
|
||||||
"specification": "Moisture",
|
"specification": "Moisture",
|
||||||
"value": "< 5%",
|
"value": "< 5%",
|
||||||
|
@ -126,12 +126,18 @@ def create_quality_inspection(**args):
|
|||||||
qa.inspected_by = frappe.session.user
|
qa.inspected_by = frappe.session.user
|
||||||
qa.status = args.status or "Accepted"
|
qa.status = args.status or "Accepted"
|
||||||
|
|
||||||
readings = args.readings or {"specification": "Size", "min_value": 0, "max_value": 10}
|
if not args.readings:
|
||||||
|
create_quality_inspection_parameter("Size")
|
||||||
|
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
|
||||||
|
|
||||||
if isinstance(readings, list):
|
if isinstance(readings, list):
|
||||||
for entry in readings:
|
for entry in readings:
|
||||||
|
create_quality_inspection_parameter(entry["specification"])
|
||||||
qa.append("readings", entry)
|
qa.append("readings", entry)
|
||||||
else:
|
else:
|
||||||
qa.append("readings", readings)
|
qa.append("readings", readings)
|
||||||
@ -142,3 +148,11 @@ def create_quality_inspection(**args):
|
|||||||
qa.submit()
|
qa.submit()
|
||||||
|
|
||||||
return qa
|
return qa
|
||||||
|
|
||||||
|
def create_quality_inspection_parameter(parameter):
|
||||||
|
if not frappe.db.exists("Quality Inspection Parameter", parameter):
|
||||||
|
frappe.get_doc({
|
||||||
|
"doctype": "Quality Inspection Parameter",
|
||||||
|
"parameter": parameter,
|
||||||
|
"description": parameter
|
||||||
|
}).insert()
|
Loading…
Reference in New Issue
Block a user