fix: move get_shipping_address() from frappe to erpnext and fix references
This commit is contained in:
parent
2f528c1c73
commit
89419c9a30
@ -3,6 +3,7 @@ from frappe import _
|
|||||||
from frappe.contacts.doctype.address.address import Address
|
from frappe.contacts.doctype.address.address import Address
|
||||||
from frappe.contacts.address_and_contact import set_link_title
|
from frappe.contacts.address_and_contact import set_link_title
|
||||||
from frappe.core.doctype.dynamic_link.dynamic_link import deduplicate_dynamic_links
|
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):
|
class CustomAddress(Address):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@ -30,4 +31,22 @@ class CustomAddress(Address):
|
|||||||
if not [row for row in self.links if row.link_doctype == "Company"]:
|
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."),
|
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"))
|
title =_("Company not Linked"))
|
||||||
|
|
||||||
|
@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)
|
||||||
|
@ -277,7 +277,7 @@ erpnext.utils.validate_mandatory = function(frm, label, value, trigger_on) {
|
|||||||
erpnext.utils.get_shipping_address = function(frm, callback){
|
erpnext.utils.get_shipping_address = function(frm, callback){
|
||||||
if (frm.doc.company) {
|
if (frm.doc.company) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "frappe.contacts.doctype.address.address.get_shipping_address",
|
method: "erpnext.accounts.custom.address.get_shipping_address",
|
||||||
args: {
|
args: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
address: frm.doc.shipping_address
|
address: frm.doc.shipping_address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user