mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
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:
@@ -297,6 +297,36 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 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_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@@ -4563,7 +4593,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2018-01-11 14:02:48.829906",
|
"modified": "2018-01-09 09:48:00.152026",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"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')
|
self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account')
|
||||||
|
|
||||||
if pos:
|
if pos:
|
||||||
|
self.allow_print_before_pay = pos.allow_print_before_pay
|
||||||
|
|
||||||
if not for_validate and not self.customer:
|
if not for_validate and not self.customer:
|
||||||
self.customer = pos.customer
|
self.customer = pos.customer
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
this.set_online_status();
|
this.set_online_status();
|
||||||
},
|
},
|
||||||
() => this.setup_company(),
|
() => this.setup_company(),
|
||||||
|
|
||||||
() => this.make_new_invoice(),
|
() => this.make_new_invoice(),
|
||||||
() => {
|
() => {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
@@ -111,6 +110,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
},
|
},
|
||||||
on_select_change: () => {
|
on_select_change: () => {
|
||||||
this.cart.numpad.set_inactive();
|
this.cart.numpad.set_inactive();
|
||||||
|
this.set_form_action();
|
||||||
},
|
},
|
||||||
get_item_details: (item_code) => {
|
get_item_details: (item_code) => {
|
||||||
return this.items.get(item_code);
|
return this.items.get(item_code);
|
||||||
@@ -180,6 +180,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
// update cart
|
// update cart
|
||||||
this.update_cart_data(item);
|
this.update_cart_data(item);
|
||||||
|
this.set_form_action();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -278,13 +279,17 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submit_sales_invoice() {
|
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.confirm(__("Permanently Submit {0}?", [this.frm.doc.name]), () => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'erpnext.selling.page.point_of_sale.point_of_sale.submit_invoice',
|
method: 'erpnext.selling.page.point_of_sale.point_of_sale.submit_invoice',
|
||||||
freeze: true,
|
freeze: true,
|
||||||
args: {
|
args: {
|
||||||
doc: this.frm.doc
|
doc: this.frm.doc,
|
||||||
|
is_saved: is_saved
|
||||||
}
|
}
|
||||||
}).then(r => {
|
}).then(r => {
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
@@ -499,19 +504,26 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_form_action() {
|
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"), () => {
|
if (this.frm.doc.docstatus == 1) {
|
||||||
this.frm.print_preview.printit(true);
|
this.page.set_primary_action(__("New"), () => {
|
||||||
});
|
this.make_new_invoice();
|
||||||
|
});
|
||||||
this.page.set_primary_action(__("New"), () => {
|
this.page.add_menu_item(__("Email"), () => {
|
||||||
this.make_new_invoice();
|
this.frm.email_doc();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
this.page.add_menu_item(__("Email"), () => {
|
|
||||||
this.frm.email_doc();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, json
|
import frappe, json
|
||||||
from frappe.utils.nestedset import get_root_of
|
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
|
from erpnext.accounts.doctype.pos_profile.pos_profile import get_item_groups
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@@ -88,11 +89,15 @@ def get_conditions(item_code, serial_no, batch_no, barcode):
|
|||||||
return '%%%s%%'%(frappe.db.escape(item_code)), condition
|
return '%%%s%%'%(frappe.db.escape(item_code)), condition
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def submit_invoice(doc):
|
def submit_invoice(doc,is_saved):
|
||||||
if isinstance(doc, basestring):
|
if isinstance(doc, basestring):
|
||||||
args = json.loads(doc)
|
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.update(args)
|
||||||
doc.run_method("set_missing_values")
|
doc.run_method("set_missing_values")
|
||||||
doc.run_method("calculate_taxes_and_totals")
|
doc.run_method("calculate_taxes_and_totals")
|
||||||
|
|||||||
Reference in New Issue
Block a user