Merge pull request #12620 from mntechnique/draft-mode-print
Print Functionality in Online POS using allow print before pay check
This commit is contained in:
commit
56a4f9205a
@ -297,6 +297,36 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "allow_print_before_pay",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Allow Print Before Pay ",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -4563,7 +4593,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2018-01-11 14:02:48.829906",
|
||||
"modified": "2018-01-09 09:48:00.152026",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice",
|
||||
|
@ -304,6 +304,8 @@ class SalesInvoice(SellingController):
|
||||
self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account')
|
||||
|
||||
if pos:
|
||||
self.allow_print_before_pay = pos.allow_print_before_pay
|
||||
|
||||
if not for_validate and not self.customer:
|
||||
self.customer = pos.customer
|
||||
|
||||
|
@ -50,7 +50,6 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
this.set_online_status();
|
||||
},
|
||||
() => this.setup_company(),
|
||||
|
||||
() => this.make_new_invoice(),
|
||||
() => {
|
||||
frappe.dom.unfreeze();
|
||||
@ -111,6 +110,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
},
|
||||
on_select_change: () => {
|
||||
this.cart.numpad.set_inactive();
|
||||
this.set_form_action();
|
||||
},
|
||||
get_item_details: (item_code) => {
|
||||
return this.items.get(item_code);
|
||||
@ -180,6 +180,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
.then(() => {
|
||||
// update cart
|
||||
this.update_cart_data(item);
|
||||
this.set_form_action();
|
||||
});
|
||||
}
|
||||
return;
|
||||
@ -278,13 +279,17 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
}
|
||||
|
||||
submit_sales_invoice() {
|
||||
|
||||
var is_saved = 0;
|
||||
if(!this.frm.doc.__islocal){
|
||||
is_saved = 1;
|
||||
}
|
||||
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,
|
||||
is_saved: is_saved
|
||||
}
|
||||
}).then(r => {
|
||||
if(r.message) {
|
||||
@ -499,19 +504,26 @@ 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.frm.doc.items.length>0)){
|
||||
this.page.set_secondary_action(__("Print"), async() => {
|
||||
if(this.frm.doc.docstatus != 1 ){
|
||||
await this.frm.save();
|
||||
}
|
||||
this.frm.print_preview.printit(true);
|
||||
});
|
||||
}
|
||||
if(this.frm.doc.items.length == 0){
|
||||
this.page.clear_secondary_action();
|
||||
}
|
||||
|
||||
this.page.set_secondary_action(__("Print"), () => {
|
||||
this.frm.print_preview.printit(true);
|
||||
});
|
||||
|
||||
this.page.set_primary_action(__("New"), () => {
|
||||
this.make_new_invoice();
|
||||
});
|
||||
|
||||
this.page.add_menu_item(__("Email"), () => {
|
||||
this.frm.email_doc();
|
||||
});
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe, json
|
||||
from frappe.utils.nestedset import get_root_of
|
||||
from frappe.utils import cint
|
||||
from erpnext.accounts.doctype.pos_profile.pos_profile import get_item_groups
|
||||
|
||||
@frappe.whitelist()
|
||||
@ -88,11 +89,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,is_saved):
|
||||
if isinstance(doc, basestring):
|
||||
args = json.loads(doc)
|
||||
|
||||
doc = frappe.new_doc('Sales Invoice')
|
||||
if(cint(is_saved) == 1):
|
||||
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")
|
||||
@ -123,4 +128,4 @@ def item_group_query(doctype, txt, searchfield, start, page_len, filters):
|
||||
return frappe.db.sql(""" select distinct name from `tabItem Group`
|
||||
where {condition} and (name like %(txt)s) limit {start}, {page_len}"""
|
||||
.format(condition = cond, start=start, page_len= page_len),
|
||||
{'txt': '%%%s%%' % txt})
|
||||
{'txt': '%%%s%%' % txt})
|
Loading…
x
Reference in New Issue
Block a user