[Mod] Ensured that a single POS Sales Invoice is created even when its printed(saved) in Draft mode

This commit is contained in:
deepak-mnt 2018-01-06 17:53:15 +05:30 committed by Saurabh
parent 1ccb0cfa2f
commit cc813d2286
2 changed files with 16 additions and 9 deletions

View File

@ -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();
});

View File

@ -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")