fix: Remove HR & Payroll from Authorization Control and Rules

This commit is contained in:
Rucha Mahabal 2022-07-01 11:28:34 +05:30
parent 7442a886a6
commit a1a6810b58
5 changed files with 191 additions and 746 deletions

View File

@ -248,61 +248,3 @@ class AuthorizationControl(TransactionBase):
)
return rule
# related to payroll module only
def get_approver_name(self, doctype_name, total, doc_obj=""):
app_user = []
app_specific_user = []
rule = {}
if doc_obj:
if doctype_name == "Expense Claim":
rule = self.get_value_based_rule(
doctype_name, doc_obj.employee, doc_obj.total_claimed_amount, doc_obj.company
)
elif doctype_name == "Appraisal":
rule = frappe.db.sql(
"""select name, to_emp, to_designation, approving_role, approving_user
from `tabAuthorization Rule` where transaction=%s
and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s))
and company = %s and docstatus!=2""",
(doctype_name, doc_obj.employee, doc_obj.employee, doc_obj.company),
as_dict=1,
)
if not rule:
rule = frappe.db.sql(
"""select name, to_emp, to_designation, approving_role, approving_user
from `tabAuthorization Rule`
where transaction=%s and (to_emp=%s or
to_designation IN (select designation from `tabEmployee` where name=%s))
and ifnull(company,'') = '' and docstatus!=2""",
(doctype_name, doc_obj.employee, doc_obj.employee),
as_dict=1,
)
if rule:
for m in rule:
if m["to_emp"] or m["to_designation"]:
if m["approving_user"]:
app_specific_user.append(m["approving_user"])
elif m["approving_role"]:
user_lst = [
z[0]
for z in frappe.db.sql(
"""select distinct t1.name
from `tabUser` t1, `tabHas Role` t2 where t2.role=%s
and t2.parent=t1.name and t1.name !='Administrator'
and t1.name != 'Guest' and t1.docstatus !=2""",
m["approving_role"],
)
]
for x in user_lst:
if not x in app_user:
app_user.append(x)
if len(app_specific_user) > 0:
return app_specific_user
else:
return app_user

View File

@ -28,19 +28,8 @@ frappe.ui.form.on("Authorization Rule", {
}
},
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']);
}
unhide_field(['system_role', 'system_user','value', 'based_on']);
hide_field(['to_emp','to_designation']);
}
})
@ -52,19 +41,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
else
unhide_field('value');
if (doc.transaction == 'Appraisal') {
hide_field(['system_role', 'system_user']);
unhide_field(['to_emp','to_designation']);
if (doc.transaction == 'Appraisal')
hide_field('value');
else
unhide_field('value');
}
else {
unhide_field(['system_role', 'system_user','value']);
hide_field(['to_emp','to_designation']);
}
unhide_field(['system_role', 'system_user','value']);
hide_field(['to_emp','to_designation']);
}
cur_frm.fields_dict.system_user.get_query = function(doc, cdt, cdn) {

View File

@ -1,657 +1,189 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "HR-ARU-.#####",
"beta": 0,
"creation": "2013-01-10 16:34:22",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"actions": [],
"allow_import": 1,
"autoname": "HR-ARU-.#####",
"creation": "2013-01-10 16:34:22",
"doctype": "DocType",
"document_type": "Setup",
"engine": "InnoDB",
"field_order": [
"transaction",
"based_on",
"customer_or_item",
"master_name",
"column_break_3",
"company",
"section_break_17",
"value",
"section_break_7",
"system_role",
"to_emp",
"column_break_10",
"system_user",
"to_designation",
"section_break_13",
"approving_role",
"column_break_15",
"approving_user"
],
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "transaction",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Transaction",
"length": 0,
"no_copy": 0,
"oldfieldname": "transaction",
"oldfieldtype": "Select",
"options": "\nSales Order\nPurchase Order\nQuotation\nDelivery Note\nSales Invoice\nPurchase Invoice\nPurchase Receipt\nAppraisal",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "transaction",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Transaction",
"oldfieldname": "transaction",
"oldfieldtype": "Select",
"options": "\nSales Order\nPurchase Order\nQuotation\nDelivery Note\nSales Invoice\nPurchase Invoice\nPurchase Receipt",
"reqd": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "based_on",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Based On",
"length": 0,
"no_copy": 0,
"oldfieldname": "based_on",
"oldfieldtype": "Select",
"options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "based_on",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Based On",
"oldfieldname": "based_on",
"oldfieldtype": "Select",
"options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable",
"reqd": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "customer_or_item",
"fieldtype": "Select",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Customer or Item",
"length": 0,
"no_copy": 0,
"options": "Customer\nItem",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "customer_or_item",
"fieldtype": "Select",
"hidden": 1,
"label": "Customer or Item",
"options": "Customer\nItem",
"read_only": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "master_name",
"fieldtype": "Dynamic Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Customer / Item Name",
"length": 0,
"no_copy": 0,
"oldfieldname": "master_name",
"oldfieldtype": "Link",
"options": "customer_or_item",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "master_name",
"fieldtype": "Dynamic Link",
"in_list_view": 1,
"label": "Customer / Item Name",
"oldfieldname": "master_name",
"oldfieldtype": "Link",
"options": "customer_or_item"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "company",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Company",
"length": 0,
"no_copy": 0,
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "company",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Company",
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
"remember_last_selected_value": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_17",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "section_break_17",
"fieldtype": "Section Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "value",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Authorized Value",
"length": 0,
"no_copy": 0,
"oldfieldname": "value",
"oldfieldtype": "Currency",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "value",
"fieldtype": "Float",
"label": "Authorized Value",
"oldfieldname": "value",
"oldfieldtype": "Currency"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "section_break_7",
"fieldtype": "Section Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "system_role",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Applicable To (Role)",
"length": 0,
"no_copy": 0,
"oldfieldname": "system_role",
"oldfieldtype": "Link",
"options": "Role",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "system_role",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Applicable To (Role)",
"oldfieldname": "system_role",
"oldfieldtype": "Link",
"options": "Role"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "",
"fieldname": "to_emp",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Applicable To (Employee)",
"length": 0,
"no_copy": 0,
"oldfieldname": "to_emp",
"oldfieldtype": "Link",
"options": "Employee",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "to_emp",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Applicable To (Employee)",
"oldfieldname": "to_emp",
"oldfieldtype": "Link",
"options": "Employee"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_10",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "column_break_10",
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "system_user",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Applicable To (User)",
"length": 0,
"no_copy": 0,
"oldfieldname": "system_user",
"oldfieldtype": "Link",
"options": "User",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "system_user",
"fieldtype": "Link",
"label": "Applicable To (User)",
"oldfieldname": "system_user",
"oldfieldtype": "Link",
"options": "User"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "",
"fieldname": "to_designation",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Applicable To (Designation)",
"length": 0,
"no_copy": 0,
"oldfieldname": "to_designation",
"oldfieldtype": "Link",
"options": "Designation",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "to_designation",
"fieldtype": "Link",
"label": "Applicable To (Designation)",
"oldfieldname": "to_designation",
"oldfieldtype": "Link",
"options": "Designation"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_13",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "section_break_13",
"fieldtype": "Section Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "approving_role",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Approving Role (above authorized value)",
"length": 0,
"no_copy": 0,
"oldfieldname": "approving_role",
"oldfieldtype": "Link",
"options": "Role",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "approving_role",
"fieldtype": "Link",
"label": "Approving Role (above authorized value)",
"oldfieldname": "approving_role",
"oldfieldtype": "Link",
"options": "Role"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_15",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"fieldname": "column_break_15",
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "approving_user",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Approving User (above authorized value)",
"length": 0,
"no_copy": 0,
"oldfieldname": "approving_user",
"oldfieldtype": "Link",
"options": "User",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"fieldname": "approving_user",
"fieldtype": "Link",
"label": "Approving User (above authorized value)",
"oldfieldname": "approving_user",
"oldfieldtype": "Link",
"options": "User"
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-shield",
"idx": 1,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-01-21 17:10:39.822125",
"modified_by": "Administrator",
"module": "Setup",
"name": "Authorization Rule",
"owner": "Administrator",
],
"icon": "fa fa-shield",
"idx": 1,
"links": [],
"modified": "2022-07-01 11:19:45.643991",
"modified_by": "Administrator",
"module": "Setup",
"name": "Authorization Rule",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"search_fields": "transaction,based_on,system_user,system_role,approving_user,approving_role",
"show_name_in_global_search": 1,
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0,
"track_views": 0
],
"search_fields": "transaction,based_on,system_user,system_role,approving_user,approving_role",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}

View File

@ -32,33 +32,31 @@ class AuthorizationRule(Document):
frappe.throw(_("Duplicate Entry. Please check Authorization Rule {0}").format(auth_exists))
def validate_rule(self):
if self.transaction != "Appraisal":
if not self.approving_role and not self.approving_user:
frappe.throw(_("Please enter Approving Role or Approving User"))
elif self.system_user and self.system_user == self.approving_user:
frappe.throw(_("Approving User cannot be same as user the rule is Applicable To"))
elif self.system_role and self.system_role == self.approving_role:
frappe.throw(_("Approving Role cannot be same as role the rule is Applicable To"))
elif self.transaction in [
"Purchase Order",
"Purchase Receipt",
"Purchase Invoice",
"Stock Entry",
] and self.based_on in [
"Average Discount",
"Customerwise Discount",
"Itemwise Discount",
]:
frappe.throw(
_("Cannot set authorization on basis of Discount for {0}").format(self.transaction)
)
elif self.based_on == "Average Discount" and flt(self.value) > 100.00:
frappe.throw(_("Discount must be less than 100"))
elif self.based_on == "Customerwise Discount" and not self.master_name:
frappe.throw(_("Customer required for 'Customerwise Discount'"))
if not self.approving_role and not self.approving_user:
frappe.throw(_("Please enter Approving Role or Approving User"))
elif self.system_user and self.system_user == self.approving_user:
frappe.throw(_("Approving User cannot be same as user the rule is Applicable To"))
elif self.system_role and self.system_role == self.approving_role:
frappe.throw(_("Approving Role cannot be same as role the rule is Applicable To"))
elif self.transaction in [
"Purchase Order",
"Purchase Receipt",
"Purchase Invoice",
"Stock Entry",
] and self.based_on in [
"Average Discount",
"Customerwise Discount",
"Itemwise Discount",
]:
frappe.throw(
_("Cannot set authorization on basis of Discount for {0}").format(self.transaction)
)
elif self.based_on == "Average Discount" and flt(self.value) > 100.00:
frappe.throw(_("Discount must be less than 100"))
elif self.based_on == "Customerwise Discount" and not self.master_name:
frappe.throw(_("Customer required for 'Customerwise Discount'"))
else:
if self.transaction == "Appraisal":
self.based_on = "Not Applicable"
self.based_on = "Not Applicable"
def validate(self):
self.check_duplicate_entry()

View File

@ -19,11 +19,6 @@ frappe.ui.form.on("Company", {
},
setup: function(frm) {
erpnext.company.setup_queries(frm);
frm.set_query("hra_component", function(){
return {
filters: {"type": "Earning"}
}
});
frm.set_query("parent_company", function() {
return {