Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to set default email recipients (backport #25555) #25914

Merged

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Apr 11, 2024

Currently, when emailing a document, users have to manually select recipients, CC and BCC (recipients sometimes get filled from the document). However, in standard processes like Sales Order -> Delivery Note -> Sales Invoice, the email addresses are often pre-defined. This is done in advance by the account manager. It should not be the responsibility of the storekeeper or accountant to figure out the correct recipient and CC addresses.

This PR enables us to set default recipients via a Client Script. Every form can programmatically supply it's own default recipients.

CommunicationComposer (the email dialog) will check if there is a client script supplying default recipients. This will allow us to do things like:

frappe.ui.form.on("Quotation", {
	get_email_recipients: function (frm, field) {
		// field can be "recipients", "cc" or "bcc"
		if (field === "bcc") {
			return [frm.doc.custom_bcc]
		}
	},
	// ...
};

Docs: frappeframework.com/docs/user/en/api/form#form-events, frappeframework.com/docs/user/en/desk/scripting/client-script#3-6-set-default-email-recipients


This is an automatic backport of pull request #25555 done by [Mergify](https://mergify.com).

* feat: add option to set default email recipients

* fix: don't crash if no events

communication.js:206 Uncaught TypeError: Cannot read properties of undefined (reading 'events')
    at frappe.views.CommunicationComposer.get_default_recipients (communication.js:206:16)
    at frappe.views.CommunicationComposer.get_fields (communication.js:57:19)
    at frappe.views.CommunicationComposer.make (communication.js:25:17)
    at new frappe.views.CommunicationComposer (communication.js:16:8)
    at Object.primary_action (communication__list_js:34:3)
    at HTMLButtonElement.<anonymous> (list_view.js:1432:19)
    at HTMLButtonElement.dispatch (jquery.js:5135:27)
    at elemData.handle (jquery.js:4939:28)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
(cherry picked from commit 4c85626)
@mergify mergify bot requested a review from a team April 11, 2024 09:27
@mergify mergify bot requested review from akhilnarang and removed request for a team April 11, 2024 09:27
@akhilnarang akhilnarang merged commit ab9a9e3 into version-15-hotfix Apr 11, 2024
18 of 20 checks passed
@akhilnarang akhilnarang deleted the mergify/bp/version-15-hotfix/pr-25555 branch April 11, 2024 09:56
@barredterra barredterra removed their assignment Apr 11, 2024
@frappe-pr-bot
Copy link
Collaborator

🎉 This PR is included in version 15.23.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants