diff --git a/erpnext/patches.txt b/erpnext/patches.txt index fd3dc3ad3cd..0abf1b42ee4 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -263,6 +263,7 @@ execute:frappe.rename_doc("Report", "TDS Payable Monthly", "Tax Withholding Deta erpnext.patches.v14_0.update_proprietorship_to_individual erpnext.patches.v15_0.rename_subcontracting_fields erpnext.patches.v15_0.unset_incorrect_additional_discount_percentage +erpnext.patches.v16_0.create_company_custom_fields [post_model_sync] erpnext.patches.v15_0.create_asset_depreciation_schedules_from_assets diff --git a/erpnext/patches/v16_0/create_company_custom_fields.py b/erpnext/patches/v16_0/create_company_custom_fields.py new file mode 100644 index 00000000000..76ab40f10b9 --- /dev/null +++ b/erpnext/patches/v16_0/create_company_custom_fields.py @@ -0,0 +1,6 @@ +from erpnext.setup.install import create_custom_company_links + + +def execute(): + """Add link fields to Company in Email Account and Communication.""" + create_custom_company_links() diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index d5f2c5422bd..9491da7ec3b 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -25,6 +25,7 @@ def after_install(): set_single_defaults() create_print_setting_custom_fields() + create_custom_company_links() add_all_roles_to("Administrator") create_default_success_action() create_default_energy_point_rules() @@ -132,6 +133,39 @@ def create_print_setting_custom_fields(): ) +def create_custom_company_links(): + """Add link fields to Company in Email Account and Communication. + + These DocTypes are provided by the Frappe Framework but need to be associated + with a company in ERPNext to allow for multitenancy. I.e. one company should + not be able to access emails and communications from another company. + """ + create_custom_fields( + { + "Email Account": [ + { + "label": _("Company"), + "fieldname": "company", + "fieldtype": "Link", + "options": "Company", + "insert_after": "email_id", + }, + ], + "Communication": [ + { + "label": _("Company"), + "fieldname": "company", + "fieldtype": "Link", + "options": "Company", + "insert_after": "email_account", + "fetch_from": "email_account.company", + "read_only": 1, + }, + ], + }, + ) + + 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")): diff --git a/erpnext/support/doctype/issue/issue.json b/erpnext/support/doctype/issue/issue.json index 622e19e9e3a..fb36538ea6c 100644 --- a/erpnext/support/doctype/issue/issue.json +++ b/erpnext/support/doctype/issue/issue.json @@ -233,6 +233,8 @@ "options": "Project" }, { + "fetch_from": "email_account.company", + "fetch_if_empty": 1, "fieldname": "company", "fieldtype": "Link", "label": "Company", @@ -391,7 +393,7 @@ "icon": "fa fa-ticket", "idx": 7, "links": [], - "modified": "2025-02-18 21:18:52.797745", + "modified": "2025-09-25 11:10:53.556731", "modified_by": "Administrator", "module": "Support", "name": "Issue",