diff --git a/erpnext/accounts/custom/address.json b/erpnext/accounts/custom/address.json deleted file mode 100644 index 5c921da9b7a..00000000000 --- a/erpnext/accounts/custom/address.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "custom_fields": [ - { - "_assign": null, - "_comments": null, - "_liked_by": null, - "_user_tags": null, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "collapsible_depends_on": null, - "columns": 0, - "creation": "2018-12-28 22:29:21.828090", - "default": null, - "depends_on": null, - "description": null, - "docstatus": 0, - "dt": "Address", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "tax_category", - "fieldtype": "Link", - "hidden": 0, - "hide_border": 0, - "hide_days": 0, - "hide_seconds": 0, - "idx": 15, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_preview": 0, - "in_standard_filter": 0, - "insert_after": "fax", - "label": "Tax Category", - "length": 0, - "mandatory_depends_on": null, - "modified": "2018-12-28 22:29:21.828090", - "modified_by": "Administrator", - "name": "Address-tax_category", - "no_copy": 0, - "options": "Tax Category", - "owner": "Administrator", - "parent": null, - "parentfield": null, - "parenttype": null, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "print_width": null, - "read_only": 0, - "read_only_depends_on": null, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "translatable": 0, - "unique": 0, - "width": null - }, - { - "_assign": null, - "_comments": null, - "_liked_by": null, - "_user_tags": null, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "collapsible_depends_on": null, - "columns": 0, - "creation": "2020-10-14 17:41:40.878179", - "default": "0", - "depends_on": null, - "description": null, - "docstatus": 0, - "dt": "Address", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "is_your_company_address", - "fieldtype": "Check", - "hidden": 0, - "hide_border": 0, - "hide_days": 0, - "hide_seconds": 0, - "idx": 20, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_preview": 0, - "in_standard_filter": 0, - "insert_after": "linked_with", - "label": "Is Your Company Address", - "length": 0, - "mandatory_depends_on": null, - "modified": "2020-10-14 17:41:40.878179", - "modified_by": "Administrator", - "name": "Address-is_your_company_address", - "no_copy": 0, - "options": null, - "owner": "Administrator", - "parent": null, - "parentfield": null, - "parenttype": null, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "print_width": null, - "read_only": 0, - "read_only_depends_on": null, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "translatable": 0, - "unique": 0, - "width": null - } - ], - "custom_perms": [], - "doctype": "Address", - "property_setters": [], - "sync_on_migrate": 1 -} \ No newline at end of file diff --git a/erpnext/erpnext_integrations/custom/contact.json b/erpnext/erpnext_integrations/custom/contact.json deleted file mode 100644 index 98a4bbc795b..00000000000 --- a/erpnext/erpnext_integrations/custom/contact.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "custom_fields": [ - { - "_assign": null, - "_comments": null, - "_liked_by": null, - "_user_tags": null, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "collapsible_depends_on": null, - "columns": 0, - "creation": "2019-12-02 11:00:03.432994", - "default": null, - "depends_on": null, - "description": null, - "docstatus": 0, - "dt": "Contact", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "is_billing_contact", - "fieldtype": "Check", - "hidden": 0, - "idx": 27, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "insert_after": "is_primary_contact", - "label": "Is Billing Contact", - "length": 0, - "modified": "2019-12-02 11:00:03.432994", - "modified_by": "Administrator", - "name": "Contact-is_billing_contact", - "no_copy": 0, - "options": null, - "owner": "Administrator", - "parent": null, - "parentfield": null, - "parenttype": null, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "print_width": null, - "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "translatable": 0, - "unique": 0, - "width": null - } - ], - "custom_perms": [], - "doctype": "Contact", - "property_setters": [], - "sync_on_migrate": 1 -} \ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 805876f2ccc..b17841bade5 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -482,3 +482,4 @@ erpnext.patches.v16_0.scr_inv_dimension erpnext.patches.v16_0.packed_item_inv_dimen erpnext.patches.v16_0.set_not_applicable_on_german_item_tax_templates erpnext.patches.v16_0.clear_procedures_from_receivable_report +erpnext.patches.v16_0.migrate_address_contact_custom_fields diff --git a/erpnext/patches/v16_0/migrate_address_contact_custom_fields.py b/erpnext/patches/v16_0/migrate_address_contact_custom_fields.py new file mode 100644 index 00000000000..6edce540eff --- /dev/null +++ b/erpnext/patches/v16_0/migrate_address_contact_custom_fields.py @@ -0,0 +1,16 @@ +import frappe + +from erpnext.setup.install import create_address_and_contact_custom_fields + + +def execute(): + """Replace fixture-based custom fields on Address and Contact with programmatic ones.""" + for custom_field in ( + "Address-tax_category", + "Address-is_your_company_address", + "Contact-is_billing_contact", + ): + if frappe.db.exists("Custom Field", custom_field): + frappe.delete_doc("Custom Field", custom_field, ignore_missing=True, force=True) + + create_address_and_contact_custom_fields() diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index b80ad82c9d3..043ac0a7193 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -25,6 +25,7 @@ def after_install(): setup_repost_defaults() create_print_setting_custom_fields() create_marketing_campaign_custom_fields() + create_address_and_contact_custom_fields() create_custom_company_links() add_all_roles_to("Administrator") create_default_success_action() @@ -145,6 +146,37 @@ def create_marketing_campaign_custom_fields(): ) +def create_address_and_contact_custom_fields(): + create_custom_fields( + { + "Address": [ + { + "label": _("Tax Category"), + "fieldname": "tax_category", + "fieldtype": "Link", + "options": "Tax Category", + "insert_after": "fax", + }, + { + "label": _("Is Your Company Address"), + "fieldname": "is_your_company_address", + "fieldtype": "Check", + "default": "0", + "insert_after": "linked_with", + }, + ], + "Contact": [ + { + "label": _("Is Billing Contact"), + "fieldname": "is_billing_contact", + "fieldtype": "Check", + "insert_after": "is_primary_contact", + }, + ], + } + ) + + def create_default_success_action(): for success_action in get_default_success_action(): if not frappe.db.exists("Success Action", success_action.get("ref_doctype")):