feat: provision to have limited parameters for in-process quality ins… (#28549)
* feat: provision to have limited parameters for in-process quality inspection
* chore: formatting
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js
index dac7b36..d85b8a6 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.js
+++ b/erpnext/manufacturing/doctype/job_card/job_card.js
@@ -76,6 +76,7 @@
frm.trigger("prepare_timer_buttons");
}
+ frm.trigger("setup_quality_inspection");
if (frm.doc.work_order) {
frappe.db.get_value('Work Order', frm.doc.work_order,
'transfer_material_against').then((r) => {
@@ -86,6 +87,22 @@
}
},
+ setup_quality_inspection: function(frm) {
+ let quality_inspection_field = frm.get_docfield("quality_inspection");
+ quality_inspection_field.get_route_options_for_new_doc = function(frm) {
+ return {
+ "inspection_type": "In Process",
+ "reference_type": "Job Card",
+ "reference_name": frm.doc.name,
+ "item_code": frm.doc.production_item,
+ "item_name": frm.doc.item_name,
+ "item_serial_no": frm.doc.serial_no,
+ "batch_no": frm.doc.batch_no,
+ "quality_inspection_template": frm.doc.quality_inspection_template,
+ };
+ };
+ },
+
setup_corrective_job_card: function(frm) {
frm.add_custom_button(__('Corrective Job Card'), () => {
let operations = frm.doc.sub_operations.map(d => d.sub_operation).concat(frm.doc.operation);
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.json b/erpnext/manufacturing/doctype/job_card/job_card.json
index 6528199..5a071f1 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.json
+++ b/erpnext/manufacturing/doctype/job_card/job_card.json
@@ -19,6 +19,7 @@
"serial_no",
"column_break_12",
"wip_warehouse",
+ "quality_inspection_template",
"quality_inspection",
"project",
"batch_no",
@@ -408,11 +409,18 @@
"no_copy": 1,
"options": "Job Card Scrap Item",
"print_hide": 1
+ },
+ {
+ "fetch_from": "operation.quality_inspection_template",
+ "fieldname": "quality_inspection_template",
+ "fieldtype": "Link",
+ "label": "Quality Inspection Template",
+ "options": "Quality Inspection Template"
}
],
"is_submittable": 1,
"links": [],
- "modified": "2021-11-12 10:15:03.572401",
+ "modified": "2021-11-24 19:17:40.879235",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Job Card",
diff --git a/erpnext/manufacturing/doctype/operation/operation.json b/erpnext/manufacturing/doctype/operation/operation.json
index 10a97ed..753552c 100644
--- a/erpnext/manufacturing/doctype/operation/operation.json
+++ b/erpnext/manufacturing/doctype/operation/operation.json
@@ -13,6 +13,7 @@
"is_corrective_operation",
"job_card_section",
"create_job_card_based_on_batch_size",
+ "quality_inspection_template",
"column_break_6",
"batch_size",
"sub_operations_section",
@@ -92,15 +93,22 @@
"fieldname": "is_corrective_operation",
"fieldtype": "Check",
"label": "Is Corrective Operation"
+ },
+ {
+ "fieldname": "quality_inspection_template",
+ "fieldtype": "Link",
+ "label": "Quality Inspection Template",
+ "options": "Quality Inspection Template"
}
],
"icon": "fa fa-wrench",
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2021-01-12 15:09:23.593338",
+ "modified": "2021-11-24 19:15:24.357187",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Operation",
+ "naming_rule": "Set by user",
"owner": "Administrator",
"permissions": [
{
diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.js b/erpnext/stock/doctype/quality_inspection/quality_inspection.js
index d08dc3e..eea2879 100644
--- a/erpnext/stock/doctype/quality_inspection/quality_inspection.js
+++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.js
@@ -59,7 +59,7 @@
},
item_code: function(frm) {
- if (frm.doc.item_code) {
+ if (frm.doc.item_code && !frm.doc.quality_inspection_template) {
return frm.call({
method: "get_quality_inspection_template",
doc: frm.doc,
diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.py b/erpnext/stock/doctype/quality_inspection/quality_inspection.py
index 913ee15..4e3b80a 100644
--- a/erpnext/stock/doctype/quality_inspection/quality_inspection.py
+++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.py
@@ -18,6 +18,15 @@
if not self.readings and self.item_code:
self.get_item_specification_details()
+ if self.inspection_type=="In Process" and self.reference_type=="Job Card":
+ item_qi_template = frappe.db.get_value("Item", self.item_code, 'quality_inspection_template')
+ parameters = get_template_details(item_qi_template)
+ for reading in self.readings:
+ for d in parameters:
+ if reading.specification == d.specification:
+ reading.update(d)
+ reading.status = "Accepted"
+
if self.readings:
self.inspect_and_set_status()