Multiple changes:
[Mod] Used async-await for asynchronous save in draft mode
[Fix] Fixed bug that din't allow to submit a new POS Invoice
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js
index a7e16af..29238ea 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -279,9 +279,9 @@
}
submit_sales_invoice() {
- var islocal_dummy = 1;
+ var is_saved = 0;
if(!this.frm.doc.__islocal){
- islocal_dummy = 0;
+ is_saved = 1;
}
frappe.confirm(__("Permanently Submit {0}?", [this.frm.doc.name]), () => {
frappe.call({
@@ -289,7 +289,7 @@
freeze: true,
args: {
doc: this.frm.doc,
- islocal_dummy: islocal_dummy
+ is_saved: is_saved
}
}).then(r => {
if(r.message) {
@@ -505,13 +505,11 @@
set_form_action() {
if(this.frm.doc.docstatus == 1 || (this.frm.doc.allow_print_before_pay == 1&&this.frm.doc.items.length>0)){
- this.page.set_secondary_action(__("Print"), () => {
+ this.page.set_secondary_action(__("Print"), async() => {
if(this.frm.doc.docstatus != 1 ){
- this.frm.save();
- setTimeout(() => {this.frm.print_preview.printit(true);}, 1700);
- }else{
- this.frm.print_preview.printit(true);
+ await this.frm.save();
}
+ this.frm.print_preview.printit(true);
});
}
if(this.frm.doc.items.length == 0){
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index 9389188..938c05d 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -88,11 +88,11 @@
return '%%%s%%'%(frappe.db.escape(item_code)), condition
@frappe.whitelist()
-def submit_invoice(doc,islocal_dummy):
+def submit_invoice(doc,is_saved):
if isinstance(doc, basestring):
args = json.loads(doc)
- if islocal_dummy:
+ if(is_saved == 1):
doc = frappe.get_doc('Sales Invoice',args["name"])
else:
doc = frappe.new_doc('Sales Invoice')