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 2991b0e2a40..bca1c16cb86 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -278,13 +278,17 @@ erpnext.pos.PointOfSale = class PointOfSale { } submit_sales_invoice() { - + var islocal_dummy = 1; + if(!this.frm.doc.__islocal){ + islocal_dummy = 0; + } frappe.confirm(__("Permanently Submit {0}?", [this.frm.doc.name]), () => { frappe.call({ method: 'erpnext.selling.page.point_of_sale.point_of_sale.submit_invoice', freeze: true, args: { - doc: this.frm.doc + doc: this.frm.doc, + islocal_dummy: islocal_dummy } }).then(r => { if(r.message) { @@ -527,12 +531,11 @@ erpnext.pos.PointOfSale = class PointOfSale { } }); } - - this.page.set_primary_action(__("New"), () => { - this.make_new_invoice(); - }); - + if (this.frm.doc.docstatus == 1) { + this.page.set_primary_action(__("New"), () => { + this.make_new_invoice(); + }); this.page.add_menu_item(__("Email"), () => { this.frm.email_doc(); }); 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 d15b05fc2e1..07dc96fb79a 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,15 @@ def get_conditions(item_code, serial_no, batch_no, barcode): return '%%%s%%'%(frappe.db.escape(item_code)), condition @frappe.whitelist() -def submit_invoice(doc): +def submit_invoice(doc,islocal_dummy): if isinstance(doc, basestring): args = json.loads(doc) - doc = frappe.new_doc('Sales Invoice') + if islocal_dummy: + doc = frappe.get_doc('Sales Invoice',args["name"]) + else: + doc = frappe.new_doc('Sales Invoice') + doc.update(args) doc.run_method("set_missing_values") doc.run_method("calculate_taxes_and_totals")