fix: print format builder setup (#7531)

This commit is contained in:
Mangesh-Khairnar 2019-05-22 15:04:42 +05:30 committed by Nabin Hait
parent 01dc6bee5b
commit 1387c331bc
2 changed files with 17 additions and 11 deletions

View file

@ -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() {

View file

@ -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