diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index dfcb88b2ff..6a035986b3 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -77,6 +77,7 @@ "email_append_to", "sender_field", "sender_name_field", + "recipient_account_field", "subject_field", "fields_tab", "fields_section", @@ -707,6 +708,12 @@ "fieldtype": "Int", "label": "Rows Threshold for Grid Search", "non_negative": 1 + }, + { + "depends_on": "email_append_to", + "fieldname": "recipient_account_field", + "fieldtype": "Data", + "label": "Recipient Account Field" } ], "grid_page_length": 50, @@ -785,7 +792,7 @@ "link_fieldname": "document_type" } ], - "modified": "2025-06-24 07:46:34.380662", + "modified": "2025-07-19 12:23:16.296416", "modified_by": "Administrator", "module": "Core", "name": "DocType", diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 1b94db76a9..845dbf5219 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -158,6 +158,7 @@ class DocType(Document): queue_in_background: DF.Check quick_entry: DF.Check read_only: DF.Check + recipient_account_field: DF.Data | None restrict_to_domain: DF.Link | None route: DF.Data | None row_format: DF.Literal["Dynamic", "Compressed"] diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index 32e25ae29e..03ac4d1761 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -49,6 +49,7 @@ "email_append_to", "sender_field", "sender_name_field", + "recipient_account_field", "subject_field", "section_break_8", "sort_field", @@ -415,6 +416,12 @@ "fieldname": "protect_attached_files", "fieldtype": "Check", "label": "Protect Attached Files" + }, + { + "depends_on": "email_append_to", + "fieldname": "recipient_account_field", + "fieldtype": "Data", + "label": "Recipient Account Field" } ], "hide_toolbar": 1, @@ -423,7 +430,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2025-03-27 18:22:32.618603", + "modified": "2025-07-19 12:23:41.564203", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form", diff --git a/frappe/custom/doctype/customize_form/customize_form.py b/frappe/custom/doctype/customize_form/customize_form.py index 3bbd874732..584882a754 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -74,6 +74,7 @@ class CustomizeForm(Document): protect_attached_files: DF.Check queue_in_background: DF.Check quick_entry: DF.Check + recipient_account_field: DF.Data | None search_fields: DF.Data | None sender_field: DF.Data | None sender_name_field: DF.Data | None diff --git a/frappe/email/receive.py b/frappe/email/receive.py index 5907528f38..a0409c7909 100644 --- a/frappe/email/receive.py +++ b/frappe/email/receive.py @@ -850,6 +850,9 @@ class InboundMail(Email): if email_fields.sender_name_field: parent.set(email_fields.sender_name_field, frappe.as_unicode(self.from_real_name)) + if email_fields.recipient_account_field: + parent.set(email_fields.recipient_account_field, self.email_account.name) + parent.flags.ignore_mandatory = True try: @@ -891,7 +894,7 @@ class InboundMail(Email): """Return Email related fields of a doctype.""" fields = frappe._dict() - email_fields = ["subject_field", "sender_field", "sender_name_field"] + email_fields = ["subject_field", "sender_field", "sender_name_field", "recipient_account_field"] meta = frappe.get_meta(doctype) for field in email_fields: