diff --git a/landa/fixtures/translation.json b/landa/fixtures/translation.json index 21b18e5a..89a471c2 100644 --- a/landa/fixtures/translation.json +++ b/landa/fixtures/translation.json @@ -4519,13 +4519,13 @@ "docstatus": 0, "doctype": "Translation", "language": "de", - "modified": "2021-12-03 17:22:26.449471", + "modified": "2023-09-26 15:40:26.449471", "name": "2418380635", "parent": null, "parentfield": null, "parenttype": null, - "source_text": "Primary Address (Full)", - "translated_text": "Prim\u00e4re Adresse (vollst\u00e4ndig)" + "source_text": "Full Address", + "translated_text": "Vollst\u00e4ndige Adresse" }, { "context": null, @@ -5807,22 +5807,6 @@ "source_text": "Pincode", "translated_text": "Postleitzahl" }, - { - "context": null, - "contributed": 0, - "contribution_docname": null, - "contribution_status": "", - "docstatus": 0, - "doctype": "Translation", - "language": "de", - "modified": "2021-09-02 17:10:49.800353", - "name": "6dc383a8a1", - "parent": null, - "parentfield": null, - "parenttype": null, - "source_text": "Primary Address (Full)", - "translated_text": "Prim\u00e4re Adresse (kommagetrennt)" - }, { "context": null, "contributed": 0, diff --git a/landa/organization_management/doctype/member_data_import/member_data_import.py b/landa/organization_management/doctype/member_data_import/member_data_import.py index 797e5a63..e8bd1697 100644 --- a/landa/organization_management/doctype/member_data_import/member_data_import.py +++ b/landa/organization_management/doctype/member_data_import/member_data_import.py @@ -173,8 +173,6 @@ def create_address( address.pincode = pincode address.city = city address.country = "Germany" - address.is_primary_address = 1 - address.is_shipping_address = 1 address.append("links", {"link_doctype": "LANDA Member", "link_name": member}) address.organization = organization diff --git a/landa/organization_management/report/external_contacts_addresses_and_contacts/external_contacts_addresses_and_contacts.py b/landa/organization_management/report/external_contacts_addresses_and_contacts/external_contacts_addresses_and_contacts.py index f7f26557..e3e5ce39 100644 --- a/landa/organization_management/report/external_contacts_addresses_and_contacts/external_contacts_addresses_and_contacts.py +++ b/landa/organization_management/report/external_contacts_addresses_and_contacts/external_contacts_addresses_and_contacts.py @@ -41,7 +41,7 @@ { "fieldname": "full_address", "fieldtype": "Data", - "label": "Primary Address (Full)", + "label": "Full Address", }, { "fieldname": "primary_email_address", @@ -103,7 +103,7 @@ def get_link_filters(link_names: List[str]): link_filters = get_link_filters(external_contact_ids) # load addresses from db - address_fields = ["address_line1", "pincode", "city", "is_primary_address"] + address_fields = ["address_line1", "pincode", "city"] addresses = frappe.get_list( "Address", filters=link_filters, @@ -111,17 +111,14 @@ def get_link_filters(link_names: List[str]): ) # convert to pandas dataframe addresses_df = to_df(addresses, address_fields) - # remove all duplicate addresses by keeping only the primary address or last existing address if there is no primary address - addresses_df = remove_duplicate_indices(addresses_df, sort_by="is_primary_address") + # remove all duplicate addresses by keeping only the last existing address + addresses_df = remove_duplicate_indices(addresses_df) # merge all columns to one address column and add this as the first column addresses_df["full_address"] = ( addresses_df["address_line1"] + ", " + addresses_df["pincode"] + " " + addresses_df["city"] ) - # remove column 'is_primary_address' - addresses_df.drop("is_primary_address", axis=1, inplace=True) - # load contacts from db that are linked to the member fucntions loaded before contact_fields = ["email_id", "phone", "mobile_no"] contacts = frappe.get_list( diff --git a/landa/organization_management/report/magazine_address_list/magazine_address_list.py b/landa/organization_management/report/magazine_address_list/magazine_address_list.py index ecfb6f7a..c3e45936 100644 --- a/landa/organization_management/report/magazine_address_list/magazine_address_list.py +++ b/landa/organization_management/report/magazine_address_list/magazine_address_list.py @@ -79,7 +79,7 @@ def get_member_filter(frappe_tuple): link_filters = get_link_filters(members) # load addresses from db - address_fields = ["address_line1", "pincode", "city", "is_primary_address"] + address_fields = ["address_line1", "pincode", "city"] addresses = frappe.get_list( "Address", filters=link_filters, @@ -88,17 +88,14 @@ def get_member_filter(frappe_tuple): ) # convert to pandas dataframe addresses_df = frappe_tuple_to_pandas_df(addresses, address_fields + ["member"]) - # remove all duplicate addresses by keeping only the primary address or last existing address if there is no primary address - addresses_df = remove_duplicate_indices(addresses_df, sort_by="is_primary_address") + # remove all duplicate addresses by keeping only the last existing address + addresses_df = remove_duplicate_indices(addresses_df) # merge all columns to one address column and add this as the first column addresses_df["full_address"] = ( addresses_df["address_line1"] + ", " + addresses_df["pincode"] + " " + addresses_df["city"] ) - # remove column 'is_primary_address' - addresses_df.drop("is_primary_address", axis=1, inplace=True) - # load addresses from db permit_fields = ["year", "member", "docstatus"] permits = frappe.get_list( @@ -182,7 +179,7 @@ def get_columns(self): { "fieldname": "full_address", "fieldtype": "Data", - "label": "Primary Address (Full)", + "label": "Full Address", }, { "fieldname": "magazine_active", diff --git a/landa/organization_management/report/member_address_list/member_address_list.json b/landa/organization_management/report/member_address_list/member_address_list.json index c921219b..021507b0 100644 --- a/landa/organization_management/report/member_address_list/member_address_list.json +++ b/landa/organization_management/report/member_address_list/member_address_list.json @@ -41,7 +41,7 @@ { "fieldname": "full_address", "fieldtype": "Data", - "label": "Primary Address (Full)", + "label": "Full Address", "width": 0 } ], diff --git a/landa/organization_management/report/member_address_list/member_address_list.py b/landa/organization_management/report/member_address_list/member_address_list.py index 769656ff..1f86255e 100644 --- a/landa/organization_management/report/member_address_list/member_address_list.py +++ b/landa/organization_management/report/member_address_list/member_address_list.py @@ -19,7 +19,7 @@ def get_data(self): link_filters = get_link_filters(self.members) # load addresses from db - address_fields = ["address_line1", "pincode", "city", "is_primary_address"] + address_fields = ["address_line1", "pincode", "city"] addresses = frappe.get_list( "Address", filters=link_filters, @@ -30,17 +30,14 @@ def get_data(self): addresses_df = pd.DataFrame(addresses, columns=address_fields + ["member"]) addresses_df.set_index("member", inplace=True) - # remove all duplicate addresses by keeping only the primary address or last existing address if there is no primary address - addresses_df = remove_duplicate_indices(addresses_df, sort_by="is_primary_address") + # remove all duplicate addresses by keeping only the last existing address + addresses_df = remove_duplicate_indices(addresses_df) # merge all columns to one address column and add this as the first column addresses_df["full_address"] = ( addresses_df["address_line1"] + ", " + addresses_df["pincode"] + " " + addresses_df["city"] ) - # remove column 'is_primary_address' - addresses_df.drop("is_primary_address", axis=1, inplace=True) - # merge all dataframes from different doctypes data = pd.concat([self.members_df, addresses_df], axis=1).reindex(self.members_df.index) @@ -83,7 +80,7 @@ def get_columns(self): { "fieldname": "full_address", "fieldtype": "Data", - "label": "Primary Address (Full)", + "label": "Full Address", }, ] diff --git a/landa/organization_management/report/members_with_member_functions/members_with_member_functions.py b/landa/organization_management/report/members_with_member_functions/members_with_member_functions.py index 30b255eb..a5b11e4b 100644 --- a/landa/organization_management/report/members_with_member_functions/members_with_member_functions.py +++ b/landa/organization_management/report/members_with_member_functions/members_with_member_functions.py @@ -53,7 +53,7 @@ { "fieldname": "full_address", "fieldtype": "Data", - "label": "Primary Address (Full)", + "label": "Full Address", }, { "fieldname": "address_line1", @@ -177,13 +177,13 @@ def get_contact_details( awards_df.drop(award_fields[:-1], axis=1, inplace=True) # load addresses from db - address_fields = ["address_line1", "pincode", "city", "is_primary_address"] + address_fields = ["address_line1", "pincode", "city"] addresses = get_contact_details("Address", MEMBERS, address_fields) # convert to pandas dataframe addresses_df = frappe_tuple_to_pandas_df(addresses, address_fields + ["member"]) - # remove all duplicate addresses by keeping only the primary address or last existing address if there is no primary address - addresses_df = remove_duplicate_indices(addresses_df, sort_by="is_primary_address") + # remove all duplicate addresses by keeping only the last existing address + addresses_df = remove_duplicate_indices(addresses_df) # merge all columns to one address column and add this as the first column addresses_df["full_address"] = ( @@ -191,8 +191,6 @@ def get_contact_details( ) address_cols = addresses_df.columns.tolist() addresses_df = addresses_df[address_cols[-1:] + address_cols[:-1]] - # remove column 'is_primary_address' - addresses_df.drop("is_primary_address", axis=1, inplace=True) # load contacts from db that are linked to the member fucntions loaded before contact_fields = ["email_id", "phone", "mobile_no"] diff --git a/landa/patches.txt b/landa/patches.txt index 39382fa5..92eabf3e 100644 --- a/landa/patches.txt +++ b/landa/patches.txt @@ -25,3 +25,4 @@ landa.patches.update_system_settings landa.patches.delete_customized_workspaces # 2023-08-14 landa.patches.build_water_body_cache # 2023-08-14 landa.patches.set_hide_custom_in_user_workspaces +landa.patches.cleanup_addresses_and_contacts diff --git a/landa/patches/cleanup_addresses_and_contacts.py b/landa/patches/cleanup_addresses_and_contacts.py new file mode 100644 index 00000000..e35c1254 --- /dev/null +++ b/landa/patches/cleanup_addresses_and_contacts.py @@ -0,0 +1,16 @@ +import frappe + + +def execute(): + cleanup_addresses() + cleanup_contacts() + + +def cleanup_addresses(): + # the two checkboxes are no longer used and are hidden from now on. + frappe.db.sql("""update `tabAddress` set is_shipping_address=0, is_primary_address=0""") + + +def cleanup_contacts(): + # the two checkboxes are no longer used and are hidden from now on. + frappe.db.sql("""update `tabContact` set is_billing_contact=0, is_primary_contact=0""") diff --git a/landa/patches/set_billing_and_shipping_defaults.py b/landa/patches/set_billing_and_shipping_defaults.py index 3e29092c..2492fdfb 100644 --- a/landa/patches/set_billing_and_shipping_defaults.py +++ b/landa/patches/set_billing_and_shipping_defaults.py @@ -8,10 +8,6 @@ def execute(): set_billing_and_shipping_defaults() - # Cleanup of data not yet now, but in the next release. Ask Samuel why. - # TODO: Clean data - # cleanup_addresses() - # cleanup_contacts() def customize_customer(): @@ -75,13 +71,3 @@ def set_billing_and_shipping_defaults(): "default_shipping_address": address_name, }, ) - - -def cleanup_addresses(): - # the two checkboxes are no longer used and are hidden from now on. - frappe.db.sql("""update `tabAddress` set is_shipping_address=0, is_primary_address=0""") - - -def cleanup_contacts(): - # the two checkboxes are no longer used and are hidden from now on. - frappe.db.sql("""update `tabContact` set is_billing_contact=0, is_primary_contact=0""") diff --git a/landa/water_body_management/report/members_in_water_body_management/members_in_water_body_management.py b/landa/water_body_management/report/members_in_water_body_management/members_in_water_body_management.py index 412892d4..8e41b6fc 100644 --- a/landa/water_body_management/report/members_in_water_body_management/members_in_water_body_management.py +++ b/landa/water_body_management/report/members_in_water_body_management/members_in_water_body_management.py @@ -55,7 +55,7 @@ { "fieldname": "full_address", "fieldtype": "Data", - "label": "Primary Address (Full)", + "label": "Full Address", }, { "fieldname": "address_line1", @@ -127,7 +127,6 @@ def get_link_filters(frappe_tuple, index="member"): "address_line1", "pincode", "city", - "is_primary_address", link_field_label, ], ) @@ -135,10 +134,10 @@ def get_link_filters(frappe_tuple, index="member"): addresses_df = pd.DataFrame.from_records( addresses, index="member", - columns=["address_line1", "pincode", "city", "is_primary_address", "member"], + columns=["address_line1", "pincode", "city", "member"], ) - # remove all duplicate addresses by keeping only the primary address or last existing address if there is no primary address - addresses_df = remove_duplicate_indices(addresses_df, sort_by="is_primary_address") + # remove all duplicate addresses by keeping only the last existing address + addresses_df = remove_duplicate_indices(addresses_df) # merge all columns to one address column and add this as the first column addresses_df["full_address"] = ( @@ -146,8 +145,6 @@ def get_link_filters(frappe_tuple, index="member"): ) address_cols = addresses_df.columns.tolist() addresses_df = addresses_df[address_cols[-1:] + address_cols[:-1]] - # remove column 'is_primary_address' - addresses_df.drop("is_primary_address", axis=1, inplace=True) # load contacts from db that are linked to the member fucntions loaded before contacts = frappe.get_all(