fix: Quality Procedure Fixes

- Dont prompt error message if parent is the same in child
- filter child procedure field
- Disable New button in tree view
- Editable grid for Quality Procedure Proces table.
This commit is contained in:
marination 2020-06-17 17:26:03 +05:30
parent 5f3cdce353
commit 8b19d01d57
5 changed files with 31 additions and 10 deletions

View File

@ -2,4 +2,13 @@
// For license information, please see license.txt
frappe.ui.form.on('Quality Procedure', {
refresh: function(frm) {
frm.set_query("procedure","processes", (frm) =>{
return {
filters: {
name: ["not in", [frm.parent_quality_procedure, frm.name]]
}
}
})
}
});

View File

@ -1,5 +1,6 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:PRC-{quality_procedure_name}",
"creation": "2018-10-06 00:06:29.756804",
"doctype": "DocType",
@ -72,7 +73,7 @@
],
"is_tree": 1,
"links": [],
"modified": "2020-03-18 18:09:29.371627",
"modified": "2020-06-17 17:25:03.434953",
"modified_by": "Administrator",
"module": "Quality Management",
"name": "Quality Procedure",

View File

@ -10,13 +10,8 @@ from frappe import _
class QualityProcedure(NestedSet):
nsm_parent_field = 'parent_quality_procedure'
def on_save(self):
for process in self.processes:
if process.procedure:
doc = frappe.get_doc("Quality Procedure", process.procedure)
if doc.parent_quality_procedure:
frappe.throw(_("{0} already has a Parent Procedure {1}.").format(process.procedure, doc.parent_quality_procedure))
self.is_group = 1
def before_save(self):
self.check_for_incorrect_child()
def on_update(self):
self.set_parent()
@ -48,11 +43,23 @@ class QualityProcedure(NestedSet):
def set_parent(self):
for process in self.processes:
if process.procedure:
# Set parent for only those children who don't have a parent
parent_quality_procedure = frappe.db.get_value("Quality Procedure", process.procedure, "parent_quality_procedure")
if not parent_quality_procedure and process.procedure:
doc = frappe.get_doc("Quality Procedure", process.procedure)
doc.parent_quality_procedure = self.name
doc.save(ignore_permissions=True)
def check_for_incorrect_child(self):
for process in self.processes:
if process.procedure:
# Check if any child process belongs to another parent.
parent_quality_procedure = frappe.db.get_value("Quality Procedure", process.procedure, "parent_quality_procedure")
if parent_quality_procedure and parent_quality_procedure != self.name:
frappe.throw(_("{0} already has a Parent Procedure {1}.".format(frappe.bold(process.procedure), frappe.bold(parent_quality_procedure))),
title=_("Invalid Child Procedure"))
self.is_group = 1
@frappe.whitelist()
def get_children(doctype, parent=None, parent_quality_procedure=None, is_root=False):
if parent is None or parent == "All Quality Procedures":

View File

@ -16,6 +16,7 @@ frappe.treeview_settings["Quality Procedure"] = {
},
],
breadcrumb: "Setup",
disable_add_node: true,
root_label: "All Quality Procedures",
get_tree_root: false,
menu_items: [

View File

@ -1,6 +1,8 @@
{
"actions": [],
"creation": "2019-05-26 00:10:00.248885",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"process_description",
@ -23,7 +25,8 @@
}
],
"istable": 1,
"modified": "2019-05-26 22:05:49.007189",
"links": [],
"modified": "2020-06-17 15:44:38.937915",
"modified_by": "Administrator",
"module": "Quality Management",
"name": "Quality Procedure Process",