[fixes] cleanup pull requests, allow printing of drafts by default
This commit is contained in:
parent
59a235ff9e
commit
b3d942e3d5
6 changed files with 42 additions and 26 deletions
|
|
@ -120,3 +120,4 @@ frappe.patches.v6_21.print_settings_repeat_header_footer
|
|||
frappe.patches.v6_24.set_language_as_code
|
||||
frappe.patches.v6_20x.update_insert_after
|
||||
frappe.patches.v6_24.sync_desktop_icons
|
||||
frappe.patches.v6_20x.set_allow_draft_for_print
|
||||
|
|
|
|||
4
frappe/patches/v6_20x/set_allow_draft_for_print.py
Normal file
4
frappe/patches/v6_20x/set_allow_draft_for_print.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.db.set_value("Print Settings", "Print Settings", "allow_print_for_draft", 1)
|
||||
|
|
@ -264,7 +264,7 @@
|
|||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"default": "1",
|
||||
"description": "Print with Letterhead, unless unchecked in a particular Document",
|
||||
"description": "",
|
||||
"fieldname": "with_letterhead",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
|
|
@ -272,7 +272,7 @@
|
|||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "With Letterhead",
|
||||
"label": "Print with letterhead",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
|
|
@ -289,7 +289,8 @@
|
|||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"description": "Allow Draft Document for Print",
|
||||
"default": "1",
|
||||
"description": "",
|
||||
"fieldname": "allow_print_for_draft",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
|
|
@ -315,7 +316,7 @@
|
|||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"description": "Allow Cancelled Document for Print.",
|
||||
"description": "",
|
||||
"fieldname": "allow_print_for_cancelled",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
|
|
@ -395,8 +396,8 @@
|
|||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-03-21 15:39:57.511678",
|
||||
"modified_by": "sangram.p@indictranstech.com",
|
||||
"modified": "2016-03-23 03:13:32.357165",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Print",
|
||||
"name": "Print Settings",
|
||||
"name_case": "",
|
||||
|
|
|
|||
|
|
@ -101,16 +101,16 @@ frappe.ui.form.Toolbar = Class.extend({
|
|||
var me = this;
|
||||
var p = this.frm.perm[0];
|
||||
var docstatus = cint(this.frm.doc.docstatus);
|
||||
var print_settings = frappe.model.get_doc(":Print Settings", "Print Settings")
|
||||
var allow_print_for_draft = cint(print_settings.allow_print_for_draft)
|
||||
var is_submittable = frappe.model.is_submittable(this.frm.doc.doctype)
|
||||
var allow_print_for_cancelled = cint(print_settings.allow_print_for_cancelled)
|
||||
|
||||
|
||||
var print_settings = frappe.model.get_doc(":Print Settings", "Print Settings")
|
||||
var allow_print_for_draft = cint(print_settings.allow_print_for_draft);
|
||||
var allow_print_for_cancelled = cint(print_settings.allow_print_for_cancelled);
|
||||
|
||||
// Print
|
||||
if(!is_submittable || docstatus == 1 ||
|
||||
(allow_print_for_cancelled && docstatus == 2)||
|
||||
(allow_print_for_draft && docstatus == 0)||
|
||||
in_list(user_roles, "Administrator")) {
|
||||
if(!is_submittable || docstatus == 1 ||
|
||||
(allow_print_for_cancelled && docstatus == 2)||
|
||||
(allow_print_for_draft && docstatus == 0)) {
|
||||
if(frappe.model.can_print(null, me.frm)) {
|
||||
this.page.add_menu_item(__("Print"), function() {
|
||||
me.frm.print_doc();}, true);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
</div>\
|
||||
<div class="results" style="display: none;">\
|
||||
<div class="result-area" style="height:400px;"></div>\
|
||||
<p class="help-msg alert-warning alert-link" style="text-align: center;"></p>\
|
||||
<p class="help-msg alert alert-warning text-center" style="margin: 15px; margin-top: 0px;"></p>\
|
||||
<p class="msg-box small">\
|
||||
'+__('For comparative filters, start with')+' ">" or "<", e.g. >5 or >01-02-2012\
|
||||
<br>'+__('For ranges')+' ('+__('values and dates')+') use ":", \
|
||||
|
|
@ -149,7 +149,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
msgprint(__("You are not allowed to print this report"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(this.html_format) {
|
||||
var content = frappe.render(this.html_format,
|
||||
{data: this.dataView.getItems(), filters:this.get_values(), report:this});
|
||||
|
|
@ -164,7 +164,7 @@ frappe.views.QueryReport = Class.extend({
|
|||
msgprint(__("You are not allowed to make PDF for this report"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(this.html_format) {
|
||||
var content = frappe.render(this.html_format,
|
||||
{data: this.dataView.getItems(), filters:this.get_values(), report:this});
|
||||
|
|
@ -708,5 +708,5 @@ frappe.views.QueryReport = Class.extend({
|
|||
} else {
|
||||
this.wrapper.find(".help-msg").empty().toggle(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -54,16 +54,26 @@ def get_print_format_doc(print_format_name, meta):
|
|||
def get_html(doc, name=None, print_format=None, meta=None,
|
||||
no_letterhead=None, trigger_print=False):
|
||||
|
||||
print_settings = frappe.db.get_singles_dict("Print Settings")
|
||||
|
||||
if isinstance(no_letterhead, basestring):
|
||||
no_letterhead = cint(no_letterhead)
|
||||
|
||||
elif no_letterhead is None:
|
||||
no_letterhead = not cint(frappe.db.get_single_value("Print Settings", "with_letterhead"))
|
||||
no_letterhead = not cint(print_settings.with_letthead)
|
||||
|
||||
doc.flags.in_print = True
|
||||
|
||||
if not frappe.flags.ignore_print_permissions:
|
||||
validate_print_permission(doc)
|
||||
|
||||
if doc.meta.is_submittable:
|
||||
if doc.docstatus==0 and not print_settings.allow_print_for_draft:
|
||||
frappe.throw(_("Not allowed to print draft documents"), frappe.PermissionError)
|
||||
|
||||
if doc.docstatus==2 and not print_settings.allow_print_for_cancelled:
|
||||
frappe.throw(_("Not allowed to print cancelled documents"), frappe.PermissionError)
|
||||
|
||||
if hasattr(doc, "before_print"):
|
||||
doc.before_print()
|
||||
|
||||
|
|
@ -149,9 +159,9 @@ def download_multi_pdf(doctype, name, format=None):
|
|||
totalhtml = ""
|
||||
# Pagebreak to be added between each doc html
|
||||
pagebreak = """<p style="page-break-after:always;"></p>"""
|
||||
|
||||
|
||||
options = {}
|
||||
|
||||
|
||||
import json
|
||||
result = json.loads(name)
|
||||
# Get html of each doc and combine including page breaks
|
||||
|
|
@ -161,12 +171,12 @@ def download_multi_pdf(doctype, name, format=None):
|
|||
totalhtml = totalhtml + html
|
||||
else:
|
||||
totalhtml = totalhtml + html + pagebreak
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
frappe.local.response.filename = "{doctype}.pdf".format(doctype=doctype.replace(" ", "-").replace("/", "-"))
|
||||
|
||||
|
||||
|
||||
# Title of pdf
|
||||
options.update({
|
||||
'title': doctype,
|
||||
|
|
@ -174,7 +184,7 @@ def download_multi_pdf(doctype, name, format=None):
|
|||
|
||||
frappe.local.response.filecontent = get_pdf(totalhtml,options)
|
||||
frappe.local.response.type = "download"
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def download_pdf(doctype, name, format=None):
|
||||
html = frappe.get_print(doctype, name, format)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue