From 8271b4c564eed2f3f752767d45a27d658206bd55 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Fri, 20 Jan 2017 14:47:15 +0530 Subject: [PATCH] [minor] fixes in address filters --- .../purchase_common/purchase_common.js | 20 ++++++------------- erpnext/public/js/queries.js | 7 +++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 720a1dc208f..c03ccc80da3 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -21,20 +21,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ if(this.frm.get_field('shipping_address')) { this.frm.set_query("shipping_address", function(){ if(me.frm.doc.customer){ - return{ - filters:{ - "customer": me.frm.doc.customer - } - } - } - else{ - return{ - filters:{ - "is_your_company_address": 1, - "company": me.frm.doc.company - } - } - } + return { + query: 'frappe.geo.doctype.address.address.address_query', + filters: { link_doctype: 'Customer', link_name: me.frm.doc.customer } + }; + } else + return erpnext.queries.company_address_query(me.frm.doc) }); } }, diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js index 1141f99623b..1963137ba91 100644 --- a/erpnext/public/js/queries.js +++ b/erpnext/public/js/queries.js @@ -68,6 +68,13 @@ $.extend(erpnext.queries, { } }, + company_address_query: function(doc) { + return { + query: 'frappe.geo.doctype.address.address.address_query', + filters: { is_your_company_address: 1, link_doctype: 'Company', link_name: doc.company || '' } + }; + }, + supplier_filter: function(doc) { if(!doc.supplier) { frappe.throw(__("Please set {0}", __(frappe.meta.get_label(doc.doctype, "supplier", doc.name))));