Skip to content

Commit

Permalink
fix: specify print_language in communication attachments
Browse files Browse the repository at this point in the history
(cherry picked from commit a4ddb74)
  • Loading branch information
ankush authored and mergify[bot] committed Feb 28, 2024
1 parent cac4205 commit 4e53b12
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions frappe/core/doctype/communication/email.py
Expand Up @@ -47,6 +47,7 @@ def make(
email_template=None,
communication_type=None,
send_after=None,
print_language=None,
**kwargs,
) -> dict[str, str]:
"""Make a new communication. Checks for email permissions for specified Document.
Expand Down Expand Up @@ -102,6 +103,7 @@ def make(
communication_type=communication_type,
add_signature=False,
send_after=send_after,
print_language=print_language,
)


Expand All @@ -128,6 +130,7 @@ def _make(
communication_type=None,
add_signature=True,
send_after=None,
print_language=None,
) -> dict[str, str]:
"""Internal method to make a new communication that ignores Permission checks."""

Expand Down Expand Up @@ -181,6 +184,7 @@ def _make(
print_format=print_format,
send_me_a_copy=send_me_a_copy,
print_letterhead=print_letterhead,
print_language=print_language,
)

emails_not_sent_to = comm.exclude_emails_list(include_sender=send_me_a_copy)
Expand Down
11 changes: 8 additions & 3 deletions frappe/core/doctype/communication/mixins.py
Expand Up @@ -184,7 +184,7 @@ def get_incoming_email_account(self):
)
return self._incoming_email_account

def mail_attachments(self, print_format=None, print_html=None):
def mail_attachments(self, print_format=None, print_html=None, print_language=None):
final_attachments = []

if print_format or print_html:
Expand All @@ -194,7 +194,7 @@ def mail_attachments(self, print_format=None, print_html=None):
"print_format_attachment": 1,
"doctype": self.reference_doctype,
"name": self.reference_name,
"lang": frappe.local.lang,
"lang": print_language or frappe.local.lang,
}
final_attachments.append(d)

Expand Down Expand Up @@ -257,6 +257,7 @@ def sendmail_input_dict(
send_me_a_copy=None,
print_letterhead=None,
is_inbound_mail_communcation=None,
print_language=None,
) -> dict:
outgoing_email_account = self.get_outgoing_email_account()
if not outgoing_email_account:
Expand All @@ -273,7 +274,9 @@ def sendmail_input_dict(
if not (recipients or cc):
return {}

final_attachments = self.mail_attachments(print_format=print_format, print_html=print_html)
final_attachments = self.mail_attachments(
print_format=print_format, print_html=print_html, print_language=print_language
)
incoming_email_account = self.get_incoming_email_account()
return {
"recipients": recipients,
Expand Down Expand Up @@ -304,12 +307,14 @@ def send_email(
send_me_a_copy=None,
print_letterhead=None,
is_inbound_mail_communcation=None,
print_language=None,
):
if input_dict := self.sendmail_input_dict(
print_html=print_html,
print_format=print_format,
send_me_a_copy=send_me_a_copy,
print_letterhead=print_letterhead,
is_inbound_mail_communcation=is_inbound_mail_communcation,
print_language=print_language,
):
frappe.sendmail(**input_dict)
9 changes: 9 additions & 0 deletions frappe/public/js/frappe/views/communication.js
Expand Up @@ -145,6 +145,14 @@ frappe.views.CommunicationComposer = class {
fieldtype: "Select",
fieldname: "select_print_format",
},
{
label: __("Print Language"),
fieldtype: "Link",
options: "Language",
fieldname: "print_language",
default: frappe.boot.lang,
depends_on: "attach_document_print",
},
{ fieldtype: "Column Break" },
{
label: __("Select Attachments"),
Expand Down Expand Up @@ -728,6 +736,7 @@ frappe.views.CommunicationComposer = class {
read_receipt: form_values.send_read_receipt,
print_letterhead: me.is_print_letterhead_checked(),
send_after: form_values.send_after ? form_values.send_after : null,
print_language: form_values.print_language,
},
btn,
callback(r) {
Expand Down

0 comments on commit 4e53b12

Please sign in to comment.