diff --git a/frappe/__init__.py b/frappe/__init__.py index 1f1fd5e7a9..e89515951f 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -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.8' +__version__ = '10.0.9' __title__ = "Frappe Framework" local = Local() @@ -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): +def attach_print(doctype, name, file_name=None, print_format=None, style=None, html=None, doc=None, lang=None): from frappe.utils import scrub_urls if not file_name: file_name = name @@ -1258,6 +1258,10 @@ def attach_print(doctype, name, file_name=None, print_format=None, style=None, h print_settings = db.get_singles_dict("Print Settings") + _lang = local.lang + + #set lang as specified in print format attachment + if lang: local.lang = lang local.flags.ignore_print_permissions = True if int(print_settings.send_print_as_pdf or 0): @@ -1272,6 +1276,8 @@ def attach_print(doctype, name, file_name=None, print_format=None, style=None, h } local.flags.ignore_print_permissions = False + #reset lang to original local lang + local.lang = _lang return out diff --git a/frappe/email/queue.py b/frappe/email/queue.py index 085dfb0c18..d6bcce6c8f 100755 --- a/frappe/email/queue.py +++ b/frappe/email/queue.py @@ -168,6 +168,7 @@ def get_email_queue(recipients, sender, subject, **kwargs): if att.get('fid'): _attachments.append(att) elif att.get("print_format_attachment") == 1: + att['lang'] = frappe.local.lang _attachments.append(att) e.attachments = json.dumps(_attachments) diff --git a/frappe/model/naming.py b/frappe/model/naming.py index 6ccc5a0a19..10cd6848ce 100644 --- a/frappe/model/naming.py +++ b/frappe/model/naming.py @@ -199,11 +199,14 @@ def _set_amended_name(doc): def append_number_if_name_exists(doctype, name, fieldname='name', separator='-'): if frappe.db.exists(doctype, name): + # should be escaped 2 times since + # python string will parse the first escape + escaped_name = re.escape(re.escape(name)) last = frappe.db.sql("""select name from `tab{doctype}` where {fieldname} regexp '^{name}{separator}[[:digit:]]+' order by length({fieldname}) desc, {fieldname} desc limit 1""".format(doctype=doctype, - name=name, fieldname=fieldname, separator=separator)) + name=escaped_name, fieldname=fieldname, separator=separator)) if last: count = str(cint(last[0][0].rsplit("-", 1)[1]) + 1) diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 19fd967897..59808efa98 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -273,7 +273,7 @@ frappe.views.CommunicationComposer = Class.extend({ this.lang_code = doc.language //On selection of language retrieve language code - $(fields.language_sel.input).click(function(){ + $(fields.language_sel.input).change(function(){ me.lang_code = this.value })