fix: move get_shipping_address() from frappe to erpnext and fix references
diff --git a/erpnext/accounts/custom/address.py b/erpnext/accounts/custom/address.py
index ac2cb05..2a98df2 100644
--- a/erpnext/accounts/custom/address.py
+++ b/erpnext/accounts/custom/address.py
@@ -3,6 +3,7 @@
from frappe.contacts.doctype.address.address import Address
from frappe.contacts.address_and_contact import set_link_title
from frappe.core.doctype.dynamic_link.dynamic_link import deduplicate_dynamic_links
+from frappe.contacts.doctype.address.address import get_address_templates
class CustomAddress(Address):
def validate(self):
@@ -30,4 +31,22 @@
if not [row for row in self.links if row.link_doctype == "Company"]:
frappe.throw(_("Address needs to be linked to a Company. Please add a row for Company in the Links table below."),
title =_("Company not Linked"))
-
\ No newline at end of file
+
+@frappe.whitelist()
+def get_shipping_address(company, address = None):
+ filters = [
+ ["Dynamic Link", "link_doctype", "=", "Company"],
+ ["Dynamic Link", "link_name", "=", company],
+ ["Address", "is_your_company_address", "=", 1]
+ ]
+ fields = ["*"]
+ if address and frappe.db.get_value('Dynamic Link',
+ {'parent': address, 'link_name': company}):
+ filters.append(["Address", "name", "=", address])
+
+ address = frappe.get_all("Address", filters=filters, fields=fields) or {}
+
+ if address:
+ address_as_dict = address[0]
+ name, address_template = get_address_templates(address_as_dict)
+ return address_as_dict.get("name"), frappe.render_template(address_template, address_as_dict)
diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js
index 44e75ae..770704e 100644
--- a/erpnext/public/js/utils/party.js
+++ b/erpnext/public/js/utils/party.js
@@ -277,7 +277,7 @@
erpnext.utils.get_shipping_address = function(frm, callback){
if (frm.doc.company) {
frappe.call({
- method: "frappe.contacts.doctype.address.address.get_shipping_address",
+ method: "erpnext.accounts.custom.address.get_shipping_address",
args: {
company: frm.doc.company,
address: frm.doc.shipping_address