fix: Create QI Parameters (links) in test cases

This commit is contained in:
marination 2021-01-04 11:10:04 +05:30
parent a69e81a151
commit 7877d5a7c2
2 changed files with 18 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import unittest
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.stock.doctype.quality_inspection.test_quality_inspection import create_quality_inspection_parameter
from six import string_types
@ -56,6 +57,8 @@ def make_quality_inspection_template():
qc = frappe.new_doc("Quality Inspection Template")
qc.quality_inspection_template_name = qc_template
create_quality_inspection_parameter("Moisture")
qc.append('item_quality_inspection_parameter', {
"specification": "Moisture",
"value": "< 5%",

View File

@ -126,12 +126,18 @@ def create_quality_inspection(**args):
qa.inspected_by = frappe.session.user
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":
readings["reading_1"] = "12" # status is auto set in child on save
if isinstance(readings, list):
for entry in readings:
create_quality_inspection_parameter(entry["specification"])
qa.append("readings", entry)
else:
qa.append("readings", readings)
@ -142,3 +148,11 @@ def create_quality_inspection(**args):
qa.submit()
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()