Commit a781c3b9 authored by Rushabh Mehta's avatar Rushabh Mehta
Browse files

Merge branch 'develop'

parents 78cbc930 8293d9dc
No related merge requests found
Showing with 42 additions and 16 deletions
+42 -16
from __future__ import unicode_literals
__version__ = "6.7.6"
__version__ = "6.7.7"
......@@ -27,7 +27,7 @@ to ERPNext.
"""
app_icon = "octicon octicon-circuit-board"
app_version = "6.7.6"
app_version = "6.7.7"
app_color = "orange"
source_link = "https://github.com/frappe/frappe"
app_license = "MIT"
......
......@@ -13,6 +13,17 @@ frappe.ui.form.on("Print Format", "refresh", function(frm) {
if(frm.doc.standard==="Yes" && user !== "Administrator") {
frm.set_intro(__("Please duplicate this to make changes"));
}
if(!frm.is_new()) {
frm.add_custom_button(__("Make Default"), function() {
frappe.call({
method: "frappe.print.doctype.print_format.print_format.make_default",
args: {
name: frm.doc.name
}
})
})
}
});
frappe.ui.form.on("Print Format", "edit_format", function(frm) {
......
......@@ -60,3 +60,17 @@ class PrintFormat(Document):
if self.doc_type:
frappe.clear_cache(doctype=self.doc_type)
@frappe.whitelist()
def make_default(name):
frappe.has_permission("Print Format", "write")
print_format = frappe.get_doc("Print Format", name)
frappe.make_property_setter({
'doctype_or_field': "DocType",
'doctype': print_format.doc_type,
'property': "default_print_format",
'value': name,
})
frappe.msgprint(frappe._("Done"))
......@@ -18,6 +18,7 @@ base_template_path = "templates/pages/print.html"
standard_format = "templates/print_formats/standard.html"
def get_context(context):
"""Build context for print"""
if not frappe.form_dict.doctype or not frappe.form_dict.name:
return {
"body": """<h1>Error</h1>
......@@ -28,7 +29,7 @@ def get_context(context):
doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name)
meta = frappe.get_meta(doc.doctype)
print_format = get_print_format_doc()
print_format = get_print_format_doc(None, meta = meta)
return {
"body": get_html(doc, print_format = print_format,
......@@ -39,13 +40,11 @@ def get_context(context):
"title": doc.get(meta.title_field) if meta.title_field else doc.name
}
def get_print_format_doc(print_format_name=None):
def get_print_format_doc(print_format_name, meta):
"""Returns print format document"""
if not print_format_name:
print_format_name = frappe.form_dict.format or "Standard"
if not print_format_name:
print_format_name = "Standard"
print_format_name = frappe.form_dict.format \
or meta.default_print_format or "Standard"
if print_format_name == "Standard":
return None
......@@ -60,12 +59,6 @@ def get_html(doc, name=None, print_format=None, meta=None,
elif no_letterhead is None:
no_letterhead = not cint(frappe.db.get_single_value("Print Settings", "with_letterhead"))
if isinstance(doc, basestring) and isinstance(name, basestring):
doc = frappe.get_doc(doc, name)
if isinstance(doc, basestring):
doc = frappe.get_doc(json.loads(doc))
doc.flags.in_print = True
if not frappe.flags.ignore_print_permissions:
......@@ -132,7 +125,15 @@ def get_html(doc, name=None, print_format=None, meta=None,
@frappe.whitelist()
def get_html_and_style(doc, name=None, print_format=None, meta=None,
no_letterhead=None, trigger_print=False):
print_format = get_print_format_doc(print_format)
"""Returns `html` and `style` of print format, used in PDF etc"""
if isinstance(doc, basestring) and isinstance(name, basestring):
doc = frappe.get_doc(doc, name)
if isinstance(doc, basestring):
doc = frappe.get_doc(json.loads(doc))
print_format = get_print_format_doc(print_format, meta=meta or frappe.get_meta(doc.doctype))
return {
"html": get_html(doc, name=name, print_format=print_format, meta=meta,
no_letterhead=no_letterhead, trigger_print=trigger_print),
......
from setuptools import setup, find_packages
version = "6.7.6"
version = "6.7.7"
with open("requirements.txt", "r") as f:
install_requires = f.readlines()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment