[Mod] Ensured that a single POS Sales Invoice is created even when its printed(saved) in Draft mode
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 2991b0e..bca1c16 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 @@
}
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 @@
}
});
}
-
- 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 d15b05f..07dc96f 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 @@
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")