From 62d2fe50d2e01b2b09349ebf6000f94628da36a4 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Thu, 14 Mar 2024 15:12:25 +0530 Subject: [PATCH 1/4] fix: sales partner address display Issue --- .../doctype/sales_partner/sales_partner.py | 30 +++++++++++-------- .../templates/generators/sales_partner.html | 20 +++++++------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py index 1047360b8464..1b3953abcf7e 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/sales_partner.py @@ -54,25 +54,31 @@ def validate(self): self.partner_website = "http://" + self.partner_website def get_context(self, context): - address = frappe.db.get_value( - "Address", {"sales_partner": self.name, "is_primary_address": 1}, "*", as_dict=True + address_names = frappe.db.get_all( + "Dynamic Link", + filters={"link_doctype": "Sales Partner", "link_name": self.name, "parenttype": "Address"}, + fields=["parent"], + as_list=True, ) - if address: - city_state = ", ".join(filter(None, [address.city, address.state])) + + addresses = [] + for address_name in address_names: + address_doc = frappe.get_doc("Address", address_name[0]) + city_state = ", ".join(filter(None, [address_doc.city, address_doc.state])) address_rows = [ - address.address_line1, - address.address_line2, + address_doc.address_line1, + address_doc.address_line2, city_state, - address.pincode, - address.country, + address_doc.pincode, + address_doc.country, ] - - context.update( + addresses.append( { - "email": address.email_id, + "email": address_doc.email_id, "partner_address": filter_strip_join(address_rows, "\n
"), - "phone": filter_strip_join(cstr(address.phone).split(","), "\n
"), + "phone": filter_strip_join(cstr(address_doc.phone).split(","), "\n
"), } ) + context["addresses"] = addresses return context diff --git a/erpnext/templates/generators/sales_partner.html b/erpnext/templates/generators/sales_partner.html index 39138d3c6cc1..9dd2db990236 100644 --- a/erpnext/templates/generators/sales_partner.html +++ b/erpnext/templates/generators/sales_partner.html @@ -8,18 +8,20 @@
- {% if logo -%} + {% if logo %}

- {%- endif %} -
- {% if partner_website -%}

{{ partner_website }}

{%- endif %} - {% if partner_address -%}

{{ partner_address }}

{%- endif %} - {% if phone -%}

{{ phone }}

{%- endif %} - {% if email -%}

{{ email }}

{%- endif %} -
+ {% endif %} + {% if addresses %} + {% for address in addresses %} +
+ {% if address.partner_address %}

{{ address.partner_address }}

{% endif %} + {% if address.phone %}

{{ address.phone }}

{% endif %} + {% if address.email %}

{{ address.email }}

{% endif %} +
+ {% endfor %} + {% endif %}

{{ description }}

From b62a6b6ab09082849a52d6a4649894300f9505ca Mon Sep 17 00:00:00 2001 From: "Nihantra C. Patel" <141945075+Nihantra-Patel@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:21:28 +0530 Subject: [PATCH 2/4] fix: sales partner address display Issue --upd --- erpnext/setup/doctype/sales_partner/sales_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py index 1b3953abcf7e..1b9e6732f832 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/sales_partner.py @@ -64,7 +64,7 @@ def get_context(self, context): addresses = [] for address_name in address_names: address_doc = frappe.get_doc("Address", address_name[0]) - city_state = ", ".join(filter(None, [address_doc.city, address_doc.state])) + city_state = ", ".join([item for item in [address_doc.city, address_doc.state] if item]) address_rows = [ address_doc.address_line1, address_doc.address_line2, From f3f6bc80423b5886634e96cc7043a3cf4f567392 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 16 Mar 2024 19:15:59 +0530 Subject: [PATCH 3/4] chore: minor cleanup --- erpnext/setup/doctype/sales_partner/sales_partner.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py index 1b9e6732f832..868cbc5b3185 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/sales_partner.py @@ -57,13 +57,12 @@ def get_context(self, context): address_names = frappe.db.get_all( "Dynamic Link", filters={"link_doctype": "Sales Partner", "link_name": self.name, "parenttype": "Address"}, - fields=["parent"], - as_list=True, + pluck=["parent"] ) addresses = [] for address_name in address_names: - address_doc = frappe.get_doc("Address", address_name[0]) + address_doc = frappe.get_doc("Address", address_name) city_state = ", ".join([item for item in [address_doc.city, address_doc.state] if item]) address_rows = [ address_doc.address_line1, From cefb8f69e5159c2c9a8b8d948a1b5ead2a44af2b Mon Sep 17 00:00:00 2001 From: "Nihantra C. Patel" <141945075+Nihantra-Patel@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:51:34 +0530 Subject: [PATCH 4/4] chore: minor cleanup | add comma --- erpnext/setup/doctype/sales_partner/sales_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py index 868cbc5b3185..a8a965d1487f 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/sales_partner.py @@ -57,7 +57,7 @@ def get_context(self, context): address_names = frappe.db.get_all( "Dynamic Link", filters={"link_doctype": "Sales Partner", "link_name": self.name, "parenttype": "Address"}, - pluck=["parent"] + pluck=["parent"], ) addresses = []