Skip to content

Commit

Permalink
feat: helper method for address display (#20900) (#20901)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0473f7b)

Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
  • Loading branch information
mergify[bot] and barredterra committed May 4, 2023
1 parent d6bfaae commit f914770
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frappe/contacts/doctype/address/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_default_address(doctype, name, sort_key="is_primary_address"):


@frappe.whitelist()
def get_address_display(address_dict):
def get_address_display(address_dict: dict | str) -> str:
if not address_dict:
return

Expand Down
19 changes: 19 additions & 0 deletions frappe/public/js/frappe/utils/address_and_contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,23 @@ $.extend(frappe.contacts, {
docname,
};
},
get_address_display: function (frm, address_field, display_field) {
if (frm.updating_party_details) {
return;
}

let _address_field = address_field || "address";
let _display_field = display_field || "address_display";

if (!frm.doc[_address_field]) {
frm.set_value(_display_field, "");
return;
}

frappe
.xcall("frappe.contacts.doctype.address.address.get_address_display", {
address_dict: frm.doc[_address_field],
})
.then((address_display) => frm.set_value(_display_field, address_display));
},
});

0 comments on commit f914770

Please sign in to comment.