Allow draft mode print in online POS

This commit is contained in:
deepak-mnt 2018-01-02 18:25:08 +05:30 committed by Saurabh
parent f8a98f5eeb
commit 29abe291c9
2 changed files with 36 additions and 11 deletions

View File

@ -50,11 +50,11 @@ erpnext.pos.PointOfSale = class PointOfSale {
this.set_online_status();
},
() => this.setup_company(),
() => this.make_new_invoice(),
() => {
frappe.dom.unfreeze();
},
() => this.fetch_pos_profile_data(),
() => this.page.set_title(__('Point of Sale'))
]);
}
@ -471,6 +471,23 @@ erpnext.pos.PointOfSale = class PointOfSale {
});
}
fetch_pos_profile_data() {
var me = this;
me.frm.doc["allow_print_before_pay"] = 0;
return new Promise(resolve => {
return this.frm.call({
method: "erpnext.selling.page.point_of_sale.point_of_sale.fetch_pos_profile_detail",
args:{
pos_profile : me.frm.doc.pos_profile
}
}).then((r) => {
me.frm.doc["allow_print_before_pay"] = r.message;
this.set_form_action();
resolve();
});
});
}
prepare_menu() {
var me = this;
this.page.clear_menu();
@ -499,19 +516,20 @@ erpnext.pos.PointOfSale = class PointOfSale {
}
set_form_action() {
if(this.frm.doc.docstatus !== 1) return;
if(this.frm.doc.docstatus == 1 || this.frm.doc.allow_print_before_pay == 1){
this.page.set_secondary_action(__("Print"), () => {
this.frm.print_preview.printit(true);
});
this.page.set_secondary_action(__("Print"), () => {
this.frm.print_preview.printit(true);
});
this.page.set_primary_action(__("New"), () => {
this.make_new_invoice();
});
this.page.set_primary_action(__("New"), () => {
this.make_new_invoice();
});
this.page.add_menu_item(__("Email"), () => {
this.frm.email_doc();
});
this.page.add_menu_item(__("Email"), () => {
this.frm.email_doc();
});
}
}
};

View File

@ -124,3 +124,10 @@ def item_group_query(doctype, txt, searchfield, start, page_len, filters):
where {condition} and (name like %(txt)s) limit {start}, {page_len}"""
.format(condition = cond, start=start, page_len= page_len),
{'txt': '%%%s%%' % txt})
@frappe.whitelist()
def fetch_pos_profile_detail(pos_profile):
doc_detail=frappe.get_doc("POS Profile",pos_profile)
print_check=doc_detail.allow_print_before_pay
return print_check