feat: add company links to Email Account and Communication (#49721)

Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
Henning Wendtland
2025-10-07 11:58:19 +02:00
committed by GitHub
parent 6cf24feffc
commit 22e4c7446e
4 changed files with 45 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ def after_install():
set_single_defaults()
create_print_setting_custom_fields()
create_marketgin_campagin_custom_fields()
create_custom_company_links()
add_all_roles_to("Administrator")
create_default_success_action()
create_incoterms()
@@ -139,6 +140,39 @@ def create_default_success_action():
doc.insert(ignore_permissions=True)
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 add_company_to_session_defaults():
settings = frappe.get_single("Session Default Settings")
settings.append("session_defaults", {"ref_doctype": "Company"})