Browse Source

Merge pull request #4311 from rmehta/auth-rule-cleanup

Auth rule cleanup
develop
Anand Doshi 9 years ago
parent
commit
f71ecbba2c
  1. 89
      erpnext/setup/doctype/authorization_rule/authorization_rule.js
  2. 237
      erpnext/setup/doctype/authorization_rule/authorization_rule.json

89
erpnext/setup/doctype/authorization_rule/authorization_rule.js

@ -1,20 +1,59 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
frappe.ui.form.on("Authorization Rule", {
refresh: function(frm) {
frm.events.set_master_type(frm);
},
set_master_type: function(frm) {
if(frm.doc.based_on==="Customerwise Discount") {
unhide_field("master_name");
frm.set_value("customer_or_item", "Customer");
} else if(frm.doc.based_on==="Itemwise Discount") {
unhide_field("master_name");
frm.set_value("customer_or_item", "Item");
} else {
frm.set_value("customer_or_item", "");
frm.set_value("master_name", "");
hide_field("master_name");
}
},
based_on: function(frm) {
frm.events.set_master_type(frm);
if (frm.doc.based_on === 'Not Applicable') {
frm.set_value("value", 0);
hide_field('value');
} else {
unhide_field('value');
}
},
transaction: function(frm) {
if (frm.doc.transaction == 'Appraisal') {
frm.set_value("based_on", "Not Applicable");
frm.set_value("master_name", "");
frm.set_value("system_role", "");
frm.set_value("system_user", "");
frm.set_value("value", 0);
hide_field(['based_on', 'system_role', 'system_user', 'value']);
unhide_field(['to_emp','to_designation']);
}
else {
unhide_field(['system_role', 'system_user','value', 'based_on']);
hide_field(['to_emp','to_designation']);
}
}
})
// Settings Module // Settings Module
cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if (doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Not Applicable')
hide_field('master_name');
else
unhide_field('master_name');
if (doc.based_on == 'Not Applicable') if (doc.based_on == 'Not Applicable')
hide_field('value'); hide_field('value');
else else
unhide_field('value'); unhide_field('value');
if (doc.transaction == 'Appraisal') { if (doc.transaction == 'Appraisal') {
hide_field(['master_name','system_role', 'system_user']); hide_field(['system_role', 'system_user']);
unhide_field(['to_emp','to_designation']); unhide_field(['to_emp','to_designation']);
if (doc.transaction == 'Appraisal') if (doc.transaction == 'Appraisal')
@ -23,45 +62,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
unhide_field('value'); unhide_field('value');
} }
else { else {
unhide_field(['master_name','system_role', 'system_user','value']); unhide_field(['system_role', 'system_user','value']);
hide_field(['to_emp','to_designation']);
}
}
cur_frm.cscript.based_on = function(doc) {
if (doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Not Applicable') {
doc.master_name = '';
refresh_field('master_name');
hide_field('master_name');
}
else
unhide_field('master_name');
if (doc.based_on == 'Not Applicable') {
doc.value =0;
refresh_field('value');
hide_field('value');
}
else
unhide_field('value');
}
cur_frm.cscript.transaction = function(doc, cdt, cdn){
if (doc.transaction == 'Appraisal') {
doc.based_on == 'Not Applicable';
doc.master_name = doc.system_role = doc.system_user = '';
refresh_many(['master_name','system_role', 'system_user', 'based_on']);
hide_field(['master_name','system_role', 'system_user']);
unhide_field(['to_emp','to_designation']);
doc.value = 0;
refresh_many('value');
hide_field('value');
}
else {
unhide_field(['master_name','system_role', 'system_user','value']);
hide_field(['to_emp','to_designation']); hide_field(['to_emp','to_designation']);
} }
} }
cur_frm.fields_dict.system_user.get_query = function(doc, cdt, cdn) { cur_frm.fields_dict.system_user.get_query = function(doc, cdt, cdn) {

237
erpnext/setup/doctype/authorization_rule/authorization_rule.json

@ -13,22 +13,22 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "company", "fieldname": "transaction",
"fieldtype": "Link", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Company", "label": "Transaction",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "company", "oldfieldname": "transaction",
"oldfieldtype": "Link", "oldfieldtype": "Select",
"options": "Company", "options": "\nSales Order\nPurchase Order\nQuotation\nDelivery Note\nSales Invoice\nPurchase Invoice\nPurchase Receipt\nAppraisal",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@ -37,17 +37,17 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "transaction", "fieldname": "based_on",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Transaction", "label": "Based On",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "transaction", "oldfieldname": "based_on",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nAppraisal", "options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
@ -61,22 +61,45 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "based_on", "fieldname": "customer_or_item",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Customer or Item",
"no_copy": 0,
"options": "Customer\nItem",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "master_name",
"fieldtype": "Dynamic Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Based On", "label": "Customer / Item Name",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "based_on", "oldfieldname": "master_name",
"oldfieldtype": "Select", "oldfieldtype": "Link",
"options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable", "options": "customer_or_item",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@ -85,18 +108,104 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "master_name", "fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"label": "Customer / Item Name", "label": "Company",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "master_name", "oldfieldname": "company",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "[Select]", "options": "Company",
"permlevel": 0,
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "section_break_17",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "value",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Authorized Value",
"no_copy": 0,
"oldfieldname": "value",
"oldfieldtype": "Currency",
"permlevel": 0,
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0, "permlevel": 0,
"precision": "",
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
@ -133,17 +242,18 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "system_user", "description": "",
"fieldname": "to_emp",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Applicable To (User)", "label": "Applicable To (Employee)",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "system_user", "oldfieldname": "to_emp",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "User", "options": "Employee",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
@ -157,18 +267,38 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"description": "This will be used for setting rule in HR module", "fieldname": "column_break_10",
"fieldname": "to_emp", "fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "system_user",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Applicable To (Employee)", "label": "Applicable To (User)",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "to_emp", "oldfieldname": "system_user",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Employee", "options": "User",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
@ -182,7 +312,7 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"description": "This will be used for setting rule in HR module", "description": "",
"fieldname": "to_designation", "fieldname": "to_designation",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -203,6 +333,27 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "section_break_13",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -213,7 +364,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Approving Role", "label": "Approving Role (above authorized value)",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "approving_role", "oldfieldname": "approving_role",
"oldfieldtype": "Link", "oldfieldtype": "Link",
@ -231,18 +382,15 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "approving_user", "fieldname": "column_break_15",
"fieldtype": "Link", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Approving User",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "approving_user",
"oldfieldtype": "Link",
"options": "User",
"permlevel": 0, "permlevel": 0,
"precision": "",
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
"report_hide": 0, "report_hide": 0,
@ -255,16 +403,17 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "value", "fieldname": "approving_user",
"fieldtype": "Float", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Above Value", "label": "Approving User (above authorized value)",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "value", "oldfieldname": "approving_user",
"oldfieldtype": "Currency", "oldfieldtype": "Link",
"options": "User",
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"read_only": 0, "read_only": 0,
@ -284,7 +433,7 @@
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"modified": "2015-10-02 07:38:38.997664", "modified": "2015-11-09 00:57:05.515494",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Authorization Rule", "name": "Authorization Rule",

Loading…
Cancel
Save