mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-23 03:10:04 +00:00
[Enhance] Quality Inspection Template (#12988)
* [Enhance] Quality Inspection Template * Test case and patch * Update make_quality_inspection_template.py
This commit is contained in:
committed by
Nabin Hait
parent
79756c44c9
commit
4e8fdf7b3f
@@ -9,15 +9,22 @@ from erpnext.controllers.item_variant import copy_attributes_to_variant, make_va
|
||||
|
||||
from six import string_types
|
||||
|
||||
class TestItemVariant(unittest.TestCase):
|
||||
def test_tables_in_template_copied_to_variant(self):
|
||||
fields = [{'field_name': 'quality_inspection_template'}]
|
||||
set_item_variant_settings(fields)
|
||||
variant = make_item_variant()
|
||||
self.assertEqual(variant.get("quality_inspection_template"), "_Test QC Template")
|
||||
|
||||
def create_variant_with_tables(item, args):
|
||||
if isinstance(args, string_types):
|
||||
args = json.loads(args)
|
||||
|
||||
qc_name = make_quality_inspection_template()
|
||||
template = frappe.get_doc("Item", item)
|
||||
template.quality_parameters.append({
|
||||
"specification": "Moisture",
|
||||
"value": "< 5%",
|
||||
})
|
||||
template.quality_inspection_template = qc_name
|
||||
template.save()
|
||||
|
||||
variant = frappe.new_doc("Item")
|
||||
variant.variant_based_on = 'Item Attribute'
|
||||
variant_attributes = []
|
||||
@@ -34,7 +41,6 @@ def create_variant_with_tables(item, args):
|
||||
|
||||
return variant
|
||||
|
||||
|
||||
def make_item_variant():
|
||||
frappe.delete_doc_if_exists("Item", "_Test Variant Item-S", force=1)
|
||||
variant = create_variant_with_tables("_Test Variant Item", '{"Test Size": "Small"}')
|
||||
@@ -43,10 +49,17 @@ def make_item_variant():
|
||||
variant.save()
|
||||
return variant
|
||||
|
||||
def make_quality_inspection_template():
|
||||
qc_template = "_Test QC Template"
|
||||
if frappe.db.exists("Quality Inspection Template", qc_template):
|
||||
return qc_template
|
||||
|
||||
class TestItemVariant(unittest.TestCase):
|
||||
def test_tables_in_template_copied_to_variant(self):
|
||||
fields = [{'field_name': 'quality_parameters'}]
|
||||
set_item_variant_settings(fields)
|
||||
variant = make_item_variant()
|
||||
self.assertNotEqual(variant.get("quality_parameters"), [])
|
||||
qc = frappe.new_doc("Quality Inspection Template")
|
||||
qc.quality_inspection_template_name = qc_template
|
||||
qc.append('item_quality_inspection_parameter', {
|
||||
"specification": "Moisture",
|
||||
"value": "< 5%",
|
||||
})
|
||||
|
||||
qc.insert()
|
||||
return qc.name
|
||||
|
||||
Reference in New Issue
Block a user