From 08f842d12ee2472fc7a33472b4f888f73d331bb8 Mon Sep 17 00:00:00 2001 From: michellealva Date: Fri, 26 Jun 2020 19:56:00 +0530 Subject: [PATCH 1/2] fix: apply filters in all transactions --- erpnext/public/js/controllers/transaction.js | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ca897dd4b17..421d44b5e76 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -159,6 +159,27 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }; }); } + if (this.frm.fields_dict["items"].grid.get_field("cost_center")) { + this.frm.set_query("cost_center", "items", function(doc) { + return { + filters: { + "company": doc.company, + "is_group": 0 + } + }; + }); + } + + if (this.frm.fields_dict["items"].grid.get_field("expense_account")) { + this.frm.set_query("expense_account", "items", function(doc) { + return { + filters: { + "company": doc.company + } + }; + }); + } + if(frappe.meta.get_docfield(this.frm.doc.doctype, "pricing_rules")) { this.frm.set_indicator_formatter('pricing_rule', function(doc) { From d5736711ce04131364b079a29b10f6ee585d3dd7 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Sun, 28 Jun 2020 11:12:20 +0530 Subject: [PATCH 2/2] fix: indentation --- erpnext/public/js/controllers/transaction.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 421d44b5e76..905f6fb80f5 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -161,7 +161,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } if (this.frm.fields_dict["items"].grid.get_field("cost_center")) { this.frm.set_query("cost_center", "items", function(doc) { - return { + return { filters: { "company": doc.company, "is_group": 0 @@ -170,9 +170,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } - if (this.frm.fields_dict["items"].grid.get_field("expense_account")) { + if (this.frm.fields_dict["items"].grid.get_field("expense_account")) { this.frm.set_query("expense_account", "items", function(doc) { - return { + return { filters: { "company": doc.company } @@ -180,7 +180,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }); } - if(frappe.meta.get_docfield(this.frm.doc.doctype, "pricing_rules")) { this.frm.set_indicator_formatter('pricing_rule', function(doc) { return (doc.rule_applied) ? "green" : "red";