From 3e2ecc342345021db6b4bcd6644da812c333ebd9 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Mon, 30 Jan 2017 16:42:35 +0530 Subject: [PATCH] [Fix] Account filter in Process Payroll and Salary Component --- .../process_payroll/process_payroll.js | 23 +++++++++++-------- .../salary_component/salary_component.js | 14 +++++++++-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js index cfb646d033..128e533ba5 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.js +++ b/erpnext/hr/doctype/process_payroll/process_payroll.js @@ -10,6 +10,19 @@ frappe.ui.form.on("Process Payroll", { frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet); }, + setup: function(frm) { + frm.set_query("payment_account", function() { + var account_types = ["Bank", "Cash"]; + return { + filters: { + "account_type": ["in", account_types], + "is_group": 0, + "company": frm.doc.company + } + } + }) + }, + refresh: function(frm) { frm.disable_save(); }, @@ -50,16 +63,6 @@ frappe.ui.form.on("Process Payroll", { } }) } - }, - account: function(frm) { - var account_types = ["Bank", "Cash"]; - return { - filters: { - "account_type": ["in", account_types], - "is_group": 0, - "company": frm.doc.company - } - } } }) diff --git a/erpnext/hr/doctype/salary_component/salary_component.js b/erpnext/hr/doctype/salary_component/salary_component.js index 3ed566e41d..870503753b 100644 --- a/erpnext/hr/doctype/salary_component/salary_component.js +++ b/erpnext/hr/doctype/salary_component/salary_component.js @@ -2,7 +2,17 @@ // For license information, please see license.txt frappe.ui.form.on('Salary Component', { - refresh: function(frm) { - + setup: function(frm) { + frm.set_query("default_account", "accounts", function(doc, cdt, cdn) { + var d = locals[cdt][cdn]; + return { + filters: { + "account_type": "Expense Account", + "root_type": "Expense", + "is_group": 0, + "company": d.company + } + } + }) } });