Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2018-02-22 14:37:33 +05:30
commit c06dfafd99
10 changed files with 68 additions and 41 deletions

View file

@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template
__version__ = '10.0.25'
__version__ = '10.1.0'
__title__ = "Frappe Framework"
local = Local()
@ -384,7 +384,7 @@ def sendmail(recipients=[], sender="", subject="No Subject", message="No Message
attachments=None, content=None, doctype=None, name=None, reply_to=None,
cc=[], bcc=[], message_id=None, in_reply_to=None, send_after=None, expose_recipients=None,
send_priority=1, communication=None, retry=1, now=None, read_receipt=None, is_notification=False,
inline_images=None, template=None, args=None, header=None):
inline_images=None, template=None, args=None, header=None, print_letterhead=False):
"""Send email using user's default **Email Account** or global default **Email Account**.
@ -433,7 +433,7 @@ def sendmail(recipients=[], sender="", subject="No Subject", message="No Message
attachments=attachments, reply_to=reply_to, cc=cc, bcc=bcc, message_id=message_id, in_reply_to=in_reply_to,
send_after=send_after, expose_recipients=expose_recipients, send_priority=send_priority,
communication=communication, now=now, read_receipt=read_receipt, is_notification=is_notification,
inline_images=inline_images, header=header)
inline_images=inline_images, header=header, print_letterhead=print_letterhead)
whitelisted = []
guest_methods = []
@ -1250,7 +1250,7 @@ def get_print(doctype=None, name=None, print_format=None, style=None, html=None,
else:
return html
def attach_print(doctype, name, file_name=None, print_format=None, style=None, html=None, doc=None, lang=None):
def attach_print(doctype, name, file_name=None, print_format=None, style=None, html=None, doc=None, lang=None, print_letterhead=False):
from frappe.utils import scrub_urls
if not file_name: file_name = name
@ -1264,15 +1264,17 @@ def attach_print(doctype, name, file_name=None, print_format=None, style=None, h
if lang: local.lang = lang
local.flags.ignore_print_permissions = True
no_letterhead = not print_letterhead
if int(print_settings.send_print_as_pdf or 0):
out = {
"fname": file_name + ".pdf",
"fcontent": get_print(doctype, name, print_format=print_format, style=style, html=html, as_pdf=True, doc=doc)
"fcontent": get_print(doctype, name, print_format=print_format, style=style, html=html, as_pdf=True, doc=doc, no_letterhead=no_letterhead)
}
else:
out = {
"fname": file_name + ".html",
"fcontent": scrub_urls(get_print(doctype, name, print_format=print_format, style=style, html=html, doc=doc)).encode("utf-8")
"fcontent": scrub_urls(get_print(doctype, name, print_format=print_format, style=style, html=html, doc=doc, no_letterhead=no_letterhead)).encode("utf-8")
}
local.flags.ignore_print_permissions = False

View file

@ -26,7 +26,8 @@ from pymysql.constants import ER
@frappe.whitelist()
def make(doctype=None, name=None, content=None, subject=None, sent_or_received = "Sent",
sender=None, sender_full_name=None, recipients=None, communication_medium="Email", send_email=False,
print_html=None, print_format=None, attachments='[]', send_me_a_copy=False, cc=None, bcc=None, flags=None,read_receipt=None):
print_html=None, print_format=None, attachments='[]', send_me_a_copy=False, cc=None, bcc=None,
flags=None, read_receipt=None, print_letterhead=True):
"""Make a new communication.
:param doctype: Reference DocType.
@ -87,6 +88,7 @@ def make(doctype=None, name=None, content=None, subject=None, sent_or_received =
frappe.db.commit()
if cint(send_email):
frappe.flags.print_letterhead = print_letterhead
comm.send(print_html, print_format, attachments, send_me_a_copy=send_me_a_copy)
return {
@ -142,7 +144,8 @@ def notify(doc, print_html=None, print_format=None, attachments=None,
enqueue(sendmail, queue="default", timeout=300, event="sendmail",
communication_name=doc.name,
print_html=print_html, print_format=print_format, attachments=attachments,
recipients=recipients, cc=cc, bcc=bcc, lang=frappe.local.lang, session=frappe.local.session)
recipients=recipients, cc=cc, bcc=bcc, lang=frappe.local.lang,
session=frappe.local.session, print_letterhead=frappe.flags.print_letterhead)
def _notify(doc, print_html=None, print_format=None, attachments=None,
recipients=None, cc=None, bcc=None):
@ -171,7 +174,8 @@ def _notify(doc, print_html=None, print_format=None, attachments=None,
delayed=True,
communication=doc.name,
read_receipt=doc.read_receipt,
is_notification=True if doc.sent_or_received =="Received" else False
is_notification=True if doc.sent_or_received =="Received" else False,
print_letterhead=True if frappe.flags.print_letterhead=='true' else False
)
def update_parent_mins_to_first_response(doc):
@ -466,7 +470,7 @@ def get_attach_link(doc, print_format):
})
def sendmail(communication_name, print_html=None, print_format=None, attachments=None,
recipients=None, cc=None, bcc=None, lang=None, session=None):
recipients=None, cc=None, bcc=None, lang=None, session=None, print_letterhead=None):
try:
if lang:
@ -477,6 +481,9 @@ def sendmail(communication_name, print_html=None, print_format=None, attachments
session['data'] = frappe._dict(session['data'])
frappe.local.session.update(session)
if print_letterhead:
frappe.flags.print_letterhead = print_letterhead
# upto 3 retries
for i in range(3):
try:

View file

@ -45,7 +45,7 @@
<td>{{ frappe.meta.get_label(doc.ref_doctype, item[0]) }}</td>
<td class="{{
key==="added" ? __("success") : __("danger") }}">
{% var item_keys = keys(item[1]).sort(); %}
{% var item_keys = Object.keys(item[1]).sort(); %}
<table class="table table-bordered">
<tbody>
{% for row_key in item_keys %}

View file

@ -24,7 +24,7 @@ def send(recipients=None, sender=None, subject=None, message=None, text_content=
attachments=None, reply_to=None, cc=[], bcc=[], message_id=None, in_reply_to=None, send_after=None,
expose_recipients=None, send_priority=1, communication=None, now=False, read_receipt=None,
queue_separately=False, is_notification=False, add_unsubscribe_link=1, inline_images=None,
header=None):
header=None, print_letterhead=False):
"""Add email to sending queue (Email Queue)
:param recipients: List of recipients.
@ -131,7 +131,8 @@ def send(recipients=None, sender=None, subject=None, message=None, text_content=
is_notification = is_notification,
inline_images = inline_images,
header=header,
now=now)
now=now,
print_letterhead=print_letterhead)
def add(recipients, sender, subject, **kwargs):
@ -169,6 +170,7 @@ def get_email_queue(recipients, sender, subject, **kwargs):
_attachments.append(att)
elif att.get("print_format_attachment") == 1:
att['lang'] = frappe.local.lang
att['print_letterhead'] = kwargs.get('print_letterhead')
_attachments.append(att)
e.attachments = json.dumps(_attachments)

View file

@ -11,7 +11,7 @@ app_color = "orange"
source_link = "https://github.com/frappe/frappe"
app_license = "MIT"
develop_version = '9.x.x-develop'
develop_version = '10.x.x-develop'
app_email = "info@frappe.io"

View file

@ -140,7 +140,7 @@ frappe.ui.form.Attachments = Class.extend({
}
me.remove_fileid(fileid);
me.frm.get_docinfo().communications.push(r.message);
me.frm.timeline.refresh();
me.frm.timeline && me.frm.timeline.refresh();
if (callback) callback();
}
});

View file

@ -61,7 +61,7 @@ $.extend(frappe.model, {
if(frappe.route_options && !doc.parent) {
$.each(frappe.route_options, function(fieldname, value) {
var df = frappe.meta.has_field(doctype, fieldname);
if(df && in_list(['Link', 'Data', 'Select'], df.fieldtype) && !df.no_copy) {
if(df && in_list(['Link', 'Data', 'Select', 'Dynamic Link'], df.fieldtype) && !df.no_copy) {
doc[fieldname]=value;
}
});

View file

@ -506,7 +506,8 @@ frappe.views.CommunicationComposer = Class.extend({
sender_full_name: form_values.sender?frappe.user.full_name():undefined,
attachments: selected_attachments,
_lang : me.lang_code,
read_receipt:form_values.send_read_receipt
read_receipt:form_values.send_read_receipt,
print_letterhead: me.is_print_letterhead_checked(),
},
btn: btn,
callback: function(r) {
@ -552,6 +553,15 @@ frappe.views.CommunicationComposer = Class.extend({
});
},
is_print_letterhead_checked: function() {
if($(this.frm.wrapper).find('.form-print-wrapper').is(':visible')){
return $(this.frm.wrapper).find('.print-letterhead').prop('checked');
} else {
return (frappe.model.get_doc(":Print Settings", "Print Settings") ||
{ with_letterhead: 1 }).with_letterhead ? true : false;
}
},
setup_earlier_reply: function() {
var fields = this.dialog.fields_dict,
signature = frappe.boot.user.email_signature || "",

View file

@ -29,6 +29,7 @@ frappe.views.TreeView = Class.extend({
this.opts = {};
this.opts.get_tree_root = true;
this.opts.show_expand_all = true;
$.extend(this.opts, opts);
this.doctype = opts.doctype;
this.args = {doctype: me.doctype};
@ -70,9 +71,11 @@ frappe.views.TreeView = Class.extend({
"padding-bottom": "25px"
});
this.page.add_inner_button(__('Expand All'), function() {
me.tree.rootnode.load_all();
});
if(this.opts.show_expand_all) {
this.page.add_inner_button(__('Expand All'), function() {
me.tree.rootnode.load_all();
});
}
if(this.opts.view_template) {
var row = $('<div class="row"><div>').appendTo(this.page.main);

View file

@ -697,7 +697,6 @@ _f.Frm.prototype.save = function(save_action, callback, btn, on_error) {
$(document.activeElement).blur();
frappe.ui.form.close_grid_form();
// let any pending js process finish
setTimeout(function() {
me._save(save_action, callback, btn, on_error, resolve);
@ -761,30 +760,34 @@ _f.Frm.prototype._save = function(save_action, callback, btn, on_error, resolve)
_f.Frm.prototype.savesubmit = function(btn, callback, on_error) {
var me = this;
this.validate_form_action("Submit");
frappe.confirm(__("Permanently Submit {0}?", [this.docname]), function() {
frappe.validated = true;
me.script_manager.trigger("before_submit").then(function() {
if(!frappe.validated) {
if(on_error) {
on_error();
}
return;
}
return me.save('Submit', function(r) {
if(r.exc) {
if (on_error) {
return new Promise(resolve => {
this.validate_form_action("Submit");
frappe.confirm(__("Permanently Submit {0}?", [this.docname]), function() {
frappe.validated = true;
me.script_manager.trigger("before_submit").then(function() {
if(!frappe.validated) {
if(on_error) {
on_error();
}
} else {
frappe.utils.play_sound("submit");
callback && callback();
me.script_manager.trigger("on_submit");
return;
}
}, btn, on_error);
});
}, on_error);
me.save('Submit', function(r) {
if(r.exc) {
if (on_error) {
on_error();
}
} else {
frappe.utils.play_sound("submit");
callback && callback();
me.script_manager.trigger("on_submit")
.then(() => resolve(me));
}
}, btn, on_error, resolve);
});
}, on_error);
});
};
_f.Frm.prototype.savecancel = function(btn, callback, on_error) {