@@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json | |||||
from .exceptions import * | from .exceptions import * | ||||
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template | 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" | __title__ = "Frappe Framework" | ||||
local = Local() | local = Local() | ||||
@@ -1250,7 +1250,7 @@ def get_print(doctype=None, name=None, print_format=None, style=None, html=None, | |||||
else: | else: | ||||
return html | 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 | from frappe.utils import scrub_urls | ||||
if not file_name: file_name = name | 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") | 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 | local.flags.ignore_print_permissions = True | ||||
if int(print_settings.send_print_as_pdf or 0): | 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 | local.flags.ignore_print_permissions = False | ||||
#reset lang to original local lang | |||||
local.lang = _lang | |||||
return out | return out | ||||
@@ -168,6 +168,7 @@ def get_email_queue(recipients, sender, subject, **kwargs): | |||||
if att.get('fid'): | if att.get('fid'): | ||||
_attachments.append(att) | _attachments.append(att) | ||||
elif att.get("print_format_attachment") == 1: | elif att.get("print_format_attachment") == 1: | ||||
att['lang'] = frappe.local.lang | |||||
_attachments.append(att) | _attachments.append(att) | ||||
e.attachments = json.dumps(_attachments) | e.attachments = json.dumps(_attachments) | ||||
@@ -199,11 +199,14 @@ def _set_amended_name(doc): | |||||
def append_number_if_name_exists(doctype, name, fieldname='name', separator='-'): | def append_number_if_name_exists(doctype, name, fieldname='name', separator='-'): | ||||
if frappe.db.exists(doctype, name): | 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}` | last = frappe.db.sql("""select name from `tab{doctype}` | ||||
where {fieldname} regexp '^{name}{separator}[[:digit:]]+' | where {fieldname} regexp '^{name}{separator}[[:digit:]]+' | ||||
order by length({fieldname}) desc, | order by length({fieldname}) desc, | ||||
{fieldname} desc limit 1""".format(doctype=doctype, | {fieldname} desc limit 1""".format(doctype=doctype, | ||||
name=name, fieldname=fieldname, separator=separator)) | |||||
name=escaped_name, fieldname=fieldname, separator=separator)) | |||||
if last: | if last: | ||||
count = str(cint(last[0][0].rsplit("-", 1)[1]) + 1) | count = str(cint(last[0][0].rsplit("-", 1)[1]) + 1) | ||||
@@ -273,7 +273,7 @@ frappe.views.CommunicationComposer = Class.extend({ | |||||
this.lang_code = doc.language | this.lang_code = doc.language | ||||
//On selection of language retrieve language code | //On selection of language retrieve language code | ||||
$(fields.language_sel.input).click(function(){ | |||||
$(fields.language_sel.input).change(function(){ | |||||
me.lang_code = this.value | me.lang_code = this.value | ||||
}) | }) | ||||