From 1b16eb766791a9cd0f3c402efbf8f28a34922180 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 24 May 2022 13:30:59 +0200 Subject: [PATCH] refactor: set queries during setup --- erpnext/stock/doctype/warehouse/warehouse.js | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js index 3d7f592153..c902abf2e0 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.js +++ b/erpnext/stock/doctype/warehouse/warehouse.js @@ -2,13 +2,31 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Warehouse", { - onload: function (frm) { - frm.set_query("default_in_transit_warehouse", function () { + setup: function (frm) { + frm.set_query("default_in_transit_warehouse", function (doc) { return { filters: { warehouse_type: "Transit", is_group: 0, - company: frm.doc.company, + company: doc.company, + }, + }; + }); + + frm.set_query("parent_warehouse", function () { + return { + filters: { + is_group: 1, + }, + }; + }); + + frm.set_query("account", function (doc) { + return { + filters: { + is_group: 0, + account_type: "Stock", + company: doc.company, }, }; }); @@ -59,24 +77,6 @@ frappe.ui.form.on("Warehouse", { fieldname: "name", doctype: "Warehouse", }; - - frm.fields_dict["parent_warehouse"].get_query = function (doc) { - return { - filters: { - is_group: 1, - }, - }; - }; - - frm.fields_dict["account"].get_query = function (doc) { - return { - filters: { - is_group: 0, - account_type: "Stock", - company: doc.company, - }, - }; - }; }, });