Skip to content

Commit

Permalink
fix: export country in Magazine Address List (LAN-853)
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Aug 31, 2024
1 parent 69dbbc8 commit d4ee722
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def get_link_filters(frappe_tuple):
def get_member_filter(frappe_tuple):
return [m[0] for m in frappe_tuple]

def append_country_if_exists(row):
if row["country"]:
return f"{row['full_address']}, {row['country']}"
return row["full_address"]

# define the member master data that are supposed to be loaded
member_fields = [
"name",
Expand All @@ -81,7 +86,7 @@ def get_member_filter(frappe_tuple):
address_filters.append(["disabled", "=", 0])

# load addresses from db
address_fields = ["address_line1", "pincode", "city"]
address_fields = ["address_line1", "pincode", "city", "country"]
addresses = frappe.get_list(
"Address",
filters=address_filters,
Expand All @@ -97,6 +102,8 @@ def get_member_filter(frappe_tuple):
addresses_df["full_address"] = (
addresses_df["address_line1"] + ", " + addresses_df["pincode"] + " " + addresses_df["city"]
)
addresses_df["country"] = addresses_df["country"].apply(lambda x: x if x != "Germany" else None)
addresses_df["full_address"] = addresses_df.apply(append_country_if_exists, axis=1)

# load addresses from db
permit_fields = ["year", "member", "docstatus"]
Expand Down Expand Up @@ -179,6 +186,7 @@ def get_columns(self):
},
{"fieldname": "pincode", "fieldtype": "Data", "label": _("Pincode")},
{"fieldname": "city", "fieldtype": "Data", "label": _("City")},
{"fieldname": "country", "fieldtype": "Data", "label": _("Country")},
{
"fieldname": "full_address",
"fieldtype": "Data",
Expand Down

0 comments on commit d4ee722

Please sign in to comment.