Pārlūkot izejas kodu

fix: Send email notification by child table fields

version-14
Deepesh Garg pirms 4 gadiem
vecāks
revīzija
fda7999bdd
2 mainītis faili ar 28 papildinājumiem un 9 dzēšanām
  1. +17
    -5
      frappe/email/doctype/notification/notification.js
  2. +11
    -4
      frappe/email/doctype/notification/notification.py

+ 17
- 5
frappe/email/doctype/notification/notification.js Parādīt failu

@@ -19,9 +19,11 @@ frappe.notification = {
}

frappe.model.with_doctype(frm.doc.document_type, function() {
let get_select_options = function(df) {
let get_select_options = function(df, parent_field) {
let select_value = parent_field ? df.fieldname + ',' + parent_field : df.fieldname;

return {
value: df.fieldname,
value: select_value,
label: df.fieldname + ' (' + __(df.label) + ')'
};
};
@@ -59,9 +61,19 @@ frappe.notification = {
let receiver_fields = [];
if (frm.doc.channel === 'Email') {
receiver_fields = $.map(fields, function(d) {
return d.options == 'Email' ||
(d.options == 'User' && d.fieldtype == 'Link')
? get_select_options(d) : null;

if (d.fieldtype == 'Table') {
let child_fields = frappe.get_doc('DocType', d.options).fields;
return $.map(child_fields, function(df) {
return df.options == 'Email' ||
(df.options == 'User' && df.fieldtype == 'Link')
? get_select_options(df, d.fieldname) : null;
});
} else {
return d.options == 'Email' ||
(d.options == 'User' && d.fieldtype == 'Link')
? get_select_options(d) : null;
}
});
} else if (in_list(['WhatsApp', 'SMS'], frm.doc.channel)) {
receiver_fields = $.map(fields, function(d) {


+ 11
- 4
frappe/email/doctype/notification/notification.py Parādīt failu

@@ -235,10 +235,17 @@ def get_context(context):
if not frappe.safe_eval(recipient.condition, None, context):
continue
if recipient.receiver_by_document_field:
email_ids_value = doc.get(recipient.receiver_by_document_field)
if validate_email_address(email_ids_value):
email_ids = email_ids_value.replace(",", "\n")
recipients = recipients + email_ids.split("\n")
fields = recipient.receiver_by_document_field.split(',')
if len(fields) > 1:
for d in doc.get(fields[1]):
email_id = d.get(fields[0])
if validate_email_address(email_id):
recipients.append(email_id)
else:
email_ids_value = doc.get(fields[0])
if validate_email_address(email_ids_value):
email_ids = email_ids_value.replace(",", "\n")
recipients = recipients + email_ids.split("\n")

if recipient.cc and "{" in recipient.cc:
recipient.cc = frappe.render_template(recipient.cc, context)


Notiek ielāde…
Atcelt
Saglabāt