[fixes] field re-structuring

This commit is contained in:
Saurabh 2016-05-12 11:48:36 +05:30
parent 1b62ecea44
commit bb95d36218
3 changed files with 384 additions and 65 deletions

View File

@ -9,14 +9,45 @@ frappe.ui.form.on('Cheque Print Template', {
frm.add_custom_button(__("Cheque Print Preview"), function() { frm.add_custom_button(__("Cheque Print Preview"), function() {
erpnext.cheque_print.view_cheque_print(frm); erpnext.cheque_print.view_cheque_print(frm);
}); });
$(frm.fields_dict.cheque_print_preview.wrapper).empty()
$("<div style='position: relative; overflow-x: scroll;'>\
<div style='width:"+ frm.doc.cheque_width + "cm; \
height: "+ frm.doc.cheque_height +"cm;\
background-image: url("+frm.doc.scanned_cheque+");\
background-repeat: no-repeat;\
background-size: cover;'>\
<span style='top: "+frm.doc.date_dist_from_top_edge+"cm;\
left: "+ flt(frm.doc.date_dist_from_left_edge) +"cm;\
position: absolute;'> "+ frappe.datetime.obj_to_user() +" </span>\
<span style='top: "+frm.doc.acc_no_dist_from_top_edge+"cm;\
left: "+ frm.doc.acc_no_dist_from_left_edge +"cm;\
position: absolute;'> Acc. No. </span>\
<span style='top:"+ frm.doc.payer_name_from_top_edge +"cm;\
left: "+ flt(frm.doc.payer_name_from_left_edge) +"cm;\
position: absolute;'> Payer Name </span>\
<span style='top:"+ frm.doc.amt_in_words_from_top_edge +"cm;\
left: "+ flt(frm.doc.amt_in_words_from_left_edge) +"cm;\
position: absolute;\
display: block;\
width: "+frm.doc.amt_in_word_width+"cm;\
line-height: "+frm.doc.amt_in_words_line_spacing+"cm;\
word-wrap: break-word;'> Amount in Words </span>\
<span style='top:"+ frm.doc.amt_in_figures_from_top_edge +"cm;\
left: "+ flt(frm.doc.amt_in_figures_from_left_edge) +"cm;\
position: absolute;'> 1000 </span>\
<span style='top:"+ frm.doc.signatory_from_top_edge +"cm;\
left: "+ flt(frm.doc.signatory_from_left_edge) +"cm;\
position: absolute;'> Signatory Name </span>\
</div>\
</div>").appendTo(frm.fields_dict.cheque_print_preview.wrapper)
} }
} }
}); });
erpnext.cheque_print.view_cheque_print = function(frm) { erpnext.cheque_print.view_cheque_print = function(frm) {
console.log("here")
console.log(frm.doc)
var dialog = new frappe.ui.Dialog({ var dialog = new frappe.ui.Dialog({
title: 'Cheque Print Preview' title: 'Cheque Print Preview'
}); });
@ -28,21 +59,31 @@ erpnext.cheque_print.view_cheque_print = function(frm) {
$(body).html("<div style='width:"+ frm.doc.cheque_width + "cm; \ $(body).html("<div style='width:"+ frm.doc.cheque_width + "cm; \
height: "+ frm.doc.cheque_height +"cm;\ height: "+ frm.doc.cheque_height +"cm;\
background-image: url("+frm.doc.cheque_scan+");\
background-repeat: no-repeat;\
background-size: cover;\
border: 1px solid black;'>\ border: 1px solid black;'>\
<span style='top: "+frm.doc.data_7+"cm;\ <span style='top: "+frm.doc.data_7+"cm;\
right: "+ flt(frm.doc.cheque_width-frm.doc.data_8) +"cm;\ left: "+ flt(frm.doc.data_8) +"cm;\
position: absolute;'> "+ frappe.datetime.obj_to_user() +" </span>\ position: absolute;'> "+ frappe.datetime.obj_to_user() +" </span>\
<span style='top: "+frm.doc.acc_no_ps+"cm;\
left: "+ frm.doc.str_loc_acc_no +"cm;\
position: absolute;'> 1234567890 </span>\
<span style='top:"+ frm.doc.data_9 +"cm;\ <span style='top:"+ frm.doc.data_9 +"cm;\
left: "+ flt(frm.doc.data_10) +"cm;\ left: "+ flt(frm.doc.data_10) +"cm;\
position: absolute;'> saurabh Palnde </span>\ position: absolute;'> Saurabh Palande </span>\
<span style='top:"+ frm.doc.data_11 +"cm;\ <span style='top:"+ frm.doc.data_11 +"cm;\
left: "+ flt(frm.doc.data_13) +"cm;\ left: "+ flt(frm.doc.data_13) +"cm;\
position: absolute;'> Forty One Thousand Six hundred And Sixty Six Only </span>\ position: absolute;\
display: block;\
width: "+frm.doc.ln_width+"cm;\
line-height: "+frm.doc.ln_spacing+"cm;\
word-wrap: break-word;'>One Crore One Lakh Forty One Thousand Six hundred And Sixty Six Only </span>\
<span style='top:"+ frm.doc.data_15 +"cm;\ <span style='top:"+ frm.doc.data_15 +"cm;\
right: "+ flt(frm.doc.cheque_width-frm.doc.data_16) +"cm;\ left: "+ flt(frm.doc.data_16) +"cm;\
position: absolute;'> 41666.00 </span>\ position: absolute;'> 1,01,41666.00 </span>\
<span style='top:"+ frm.doc.data_17 +"cm;\ <span style='top:"+ frm.doc.data_17 +"cm;\
right: "+ flt(frm.doc.cheque_width-frm.doc.data_18) +"cm;\ left: "+ flt(frm.doc.data_18) +"cm;\
position: absolute;'> Frappe Technologies Pvt Ltd </span>\ position: absolute;'> Frappe Technologies Pvt Ltd </span>\
</div>") </div>")

View File

@ -14,16 +14,18 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"description": "",
"fieldname": "settings", "fieldname": "settings",
"fieldtype": "Section Break", "fieldtype": "HTML",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Settings", "label": "",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "<div>\n<h1> All dimensions in CM only </h1>\n</div>",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -39,16 +41,16 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "html_2", "fieldname": "cheque_details",
"fieldtype": "HTML", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Cheque Details",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "<div class=\"small\">\n<b>(All dimensions in CM only)</b>\n</div>",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -85,6 +87,55 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "scanned_cheque",
"fieldtype": "Attach",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Scanned Cheque",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "column_break_5",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -139,13 +190,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "section_break_6", "fieldname": "date_settings",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Date Settings",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -163,14 +215,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_7", "fieldname": "date_dist_from_top_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Distance of date line from top edge", "label": "Distance from top edge",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -188,14 +240,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_8", "fieldname": "date_dist_from_left_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Starting location of Date from left edge", "label": "Starting location from left edge",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -213,13 +265,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "section_break_9", "fieldname": "payer_settings",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Payer Settings",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -237,14 +290,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_9", "fieldname": "payer_name_from_top_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Distance of Party name line from top edge", "label": "Distance from top edge",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -262,18 +315,18 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_10", "fieldname": "payer_name_from_left_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Starting location of name from left edge", "label": "Starting location from left edge",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "2",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
@ -287,13 +340,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "section_break_12", "fieldname": "amount_in_words",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Amount In Words",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -311,14 +365,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_11", "fieldname": "amt_in_words_from_top_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Distance of amount in word line from top edge", "label": "Distance from top edge",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -336,14 +390,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_13", "fieldname": "amt_in_words_from_left_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Starting location of amount in words from left edge", "label": "Starting location from left edge",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -361,38 +415,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "column_break_6", "fieldname": "amt_in_word_width",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "data_15",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Distance of amount in figures line from top edge", "label": "Width of amount in word",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -410,14 +440,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_16", "fieldname": "amt_in_words_line_spacing",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Starting location of amount in figures from left edge", "label": "Line spacing for amount in words",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -435,13 +465,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "section_break_17", "fieldname": "amount_in_figure",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Amount In Figure",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -459,14 +490,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_17", "fieldname": "amt_in_figures_from_top_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Distance of company signature from top edge", "label": "Distance from top edge",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -484,14 +515,213 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "data_18", "fieldname": "amt_in_figures_from_left_edge",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Starting location of company signature from left edge", "label": "Starting location from left edge",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "2",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "account_number_dimensions",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Account Number Dimensions",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "acc_no_dist_from_top_edge",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Distance from top edge",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "2",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "acc_no_dist_from_left_edge",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Starting location from left edge",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "2",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "signatory_position",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Signatory Position",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "signatory_from_top_edge",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Distance from top edge",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "2",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "signatory_from_left_edge",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Starting location from left edge",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "2",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "preview",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Preview",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "cheque_print_preview",
"fieldtype": "HTML",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -514,8 +744,8 @@
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 1,
"modified": "2016-05-04 17:07:43.700169", "modified": "2016-05-11 19:50:25.554911",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Cheque Print Template", "name": "Cheque Print Template",

View File

@ -5,6 +5,54 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils import flt, cstr
class ChequePrintTemplate(Document): class ChequePrintTemplate(Document):
pass def on_update(self):
if not frappe.db.exists("Print Format", self.name):
cheque_print = frappe.new_doc("Print Format")
cheque_print.update({
"doc_type": "Journal Entry",
"standard": "Yes",
"custom_format": 1,
"print_format_type": "Server",
"name": self.name
})
else:
cheque_print = frappe.get_doc("Print Format", self.name)
cheque_print.html = """
<div style="position: relative">
<div style="width:%scm;height:%scm;">
<span style="top:%s cm; left:%scm;position: absolute;">
{{doc.cheque_date or '' }}
</span>
<span style="top:%scm;left:%scm;position: absolute;">
1234567890
</span>
<span style="top:%scm;left: %scm; position: absolute;">
{{doc.pay_to_recd_from}}
</span>
<span style="top:%scm; left:%scm; position: absolute; display: block;
width: %scm; line-height:%scm; word-wrap: break-word;">
{{doc.total_amount_in_words}}
</span>
<span style="top:%scm;left: %scm;position: absolute;">
{{doc.get_formatted("total_amount")}}
</span>
<span style="top:%scm;left: %scm; position: absolute;">
{{doc.company}}
</span>
</div>"""%(self.cheque_width, self.cheque_height,
self.date_dist_from_top_edge, self.date_dist_from_left_edge,
self.acc_no_dist_from_top_edge, self.acc_no_dist_from_left_edge,
self.payer_name_from_top_edge, self.payer_name_from_left_edge,
self.amt_in_words_from_top_edge, self.amt_in_words_from_left_edge,
self.amt_in_word_width, self.amt_in_words_line_spacing,
self.amt_in_figures_from_top_edge, self.amt_in_figures_from_left_edge,
self.signatory_from_top_edge, self.signatory_from_left_edge)
cheque_print.save(ignore_permissions=True)