diff --git a/frappe/printing/page/print_format_builder/print_format_builder.js b/frappe/printing/page/print_format_builder/print_format_builder.js index aa733cbe31..160af10c6e 100644 --- a/frappe/printing/page/print_format_builder/print_format_builder.js +++ b/frappe/printing/page/print_format_builder/print_format_builder.js @@ -130,15 +130,21 @@ frappe.PrintFormatBuilder = Class.extend({ }); }, setup_new_print_format: function(doctype, name, based_on) { - frappe.call('frappe.printing.page.print_format_builder.print_format_builder.create_custom_format', { - doctype, - name, - based_on - }).then((r) => { - frappe.model.with_doc('Print Format', r.message.name) - .then(() => $(document).trigger({ type: 'new-print-format', print_format: r.message.name })); - this.print_format = r.message; - this.refresh(); + frappe.call({ + method: 'frappe.printing.page.print_format_builder.print_format_builder.create_custom_format', + args: { + doctype: doctype, + name: name, + based_on: based_on + }, + callback: (r) => { + if(!r.exc) { + if(r.message) { + this.print_format = r.message; + this.refresh(); + } + } + }, }); }, setup_print_format: function() { diff --git a/frappe/printing/page/print_format_builder/print_format_builder.py b/frappe/printing/page/print_format_builder/print_format_builder.py index 17baa9314e..d9f57762b0 100644 --- a/frappe/printing/page/print_format_builder/print_format_builder.py +++ b/frappe/printing/page/print_format_builder/print_format_builder.py @@ -1,7 +1,7 @@ import frappe @frappe.whitelist() -def create_custom_format(doctype, name, based_on): +def create_custom_format(doctype, name, based_on='Standard'): doc = frappe.new_doc('Print Format') doc.doc_type = doctype doc.name = name @@ -9,4 +9,4 @@ def create_custom_format(doctype, name, based_on): doc.format_data = frappe.db.get_value('Print Format', based_on, 'format_data') \ if based_on != 'Standard' else None doc.insert() - return doc + return doc \ No newline at end of file