diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.js b/erpnext/accounts/doctype/pos_profile/pos_profile.js index 03d84e9ad6f..97bbc1227f1 100755 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.js +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.js @@ -8,10 +8,6 @@ frappe.ui.form.on("POS Profile", "onload", function(frm) { return { filters: { selling: 1 } }; }); - frm.set_query("print_format", function() { - return { filters: { doc_type: "Sales Invoice", print_format_type: "Js"} }; - }); - erpnext.queries.setup_queries(frm, "Warehouse", function() { return erpnext.queries.warehouse(frm.doc); }); @@ -27,6 +23,27 @@ frappe.ui.form.on("POS Profile", "onload", function(frm) { }); frappe.ui.form.on('POS Profile', { + setup: function(frm) { + frm.set_query("online_print_format", function() { + return { + filters: [ + ['Print Format', 'doc_type', '=', 'Sales Invoice'], + ['Print Format', 'print_format_type', '!=', 'Js'], + ] + }; + }); + + frm.set_query("print_format", function() { + return { filters: { doc_type: "Sales Invoice", print_format_type: "Js"} }; + }); + + frappe.db.get_value('POS Settings', {name: 'POS Settings'}, 'is_online', (r) => { + is_online = r && cint(r.is_online) + frm.toggle_display('offline_pos_section', !is_online); + frm.toggle_display('print_format_for_online', is_online); + }); + }, + refresh: function(frm) { if(frm.doc.company) { frm.trigger("toggle_display_account_head"); diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json index c4e6dabc17f..187454ef332 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.json +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json @@ -631,8 +631,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "Point of Sale", - "fieldname": "print_format", + "fieldname": "print_format_for_online", "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, @@ -641,7 +640,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Print Format", + "label": "Print Format for Online", "length": 0, "no_copy": 0, "options": "Print Format", @@ -883,7 +882,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "customer_details", + "fieldname": "offline_pos_section", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, @@ -892,7 +891,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "New Customer Details", + "label": "Offline POS Section", "length": 0, "no_copy": 0, "permlevel": 0, @@ -969,6 +968,38 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "Point of Sale", + "fieldname": "print_format", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Print Format", + "length": 0, + "no_copy": 0, + "options": "Print Format", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "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, @@ -1291,7 +1322,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-08-27 16:39:00.713225", + "modified": "2017-09-01 15:55:14.890452", "modified_by": "Administrator", "module": "Accounts", "name": "POS Profile", diff --git a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json index 28c853cc48d..4e69cad06bc 100644 --- a/erpnext/accounts/print_format/point_of_sale/point_of_sale.json +++ b/erpnext/accounts/print_format/point_of_sale/point_of_sale.json @@ -10,7 +10,7 @@ "html": "\n\n
\n\t{{ company }}
\n\t{{ __(\"POS No : \") }} {{ offline_pos_name }}
\n
\n\t{{ __(\"Customer\") }}: {{ customer }}
\n
\n\t{{ __(\"Date\") }}: {{ dateutil.global_date_format(posting_date) }}
\n
| {{ __(\"Item\") }} | \n\t\t\t{{ __(\"Qty\") }} | \n\t\t\t{{ __(\"Amount\") }} | \n\t\t
|---|---|---|
| \n\t\t\t\t{{ item.item_name }}\n\t\t\t | \n\t\t\t{{ format_number(item.qty, null,precision(\"difference\")) }} @ {{ format_currency(item.rate, currency) }} | \n\t\t\t{{ format_currency(item.amount, currency) }} | \n\t\t
| \n\t\t\t\t{{ __(\"Net Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ format_currency(total, currency) }}\n\t\t\t | \n\t\t
| \n\t\t\t\t{{ row.description }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ format_currency(row.tax_amount, currency) }}\n\t\t\t | \n\t\t
| \n\t\t\t\t{{ __(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ format_currency(discount_amount, currency) }}\n\t\t\t | \n\t\t
| \n\t\t\t\t{{ __(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ format_currency(grand_total, currency) }}\n\t\t\t | \n\t\t
| \n\t\t\t\t{{ __(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ format_currency(paid_amount, currency) }}\n\t\t\t | \n\t\t
{{ terms }}
\n{{ __(\"Thank you, please visit again.\") }}
", "idx": 0, "line_breaks": 0, - "modified": "2017-05-19 14:36:04.740728", + "modified": "2017-09-01 14:27:04.871233", "modified_by": "Administrator", "module": "Accounts", "name": "Point of Sale", diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 3a8ddb59278..f2c3d6057cf 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -4,6 +4,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ setup: function() { this._super(); + frappe.flags.hide_serial_batch_dialog = false; frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) { var item = frappe.get_doc(cdt, cdn); var has_margin_field = frappe.meta.has_field(cdt, 'margin_type'); @@ -314,12 +315,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ if(!r.exc) { me.frm.script_manager.trigger("price_list_rate", cdt, cdn); me.toggle_conversion_factor(item); - if(show_batch_dialog) { + if(show_batch_dialog && !frappe.flags.hide_serial_batch_dialog) { var d = locals[cdt][cdn]; $.each(r.message, function(k, v) { if(!d[k]) d[k] = v; }); - erpnext.show_serial_batch_selector(me.frm, d); + + erpnext.show_serial_batch_selector(me.frm, d, (item) => { + me.frm.script_manager.trigger('qty', item.doctype, item.name); + }); } } } @@ -1102,7 +1106,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }, }); -erpnext.show_serial_batch_selector = function(frm, d) { +erpnext.show_serial_batch_selector = function(frm, d, callback, show_dialog) { frappe.require("assets/erpnext/js/utils/serial_no_batch_selector.js", function() { new erpnext.SerialNoBatchSelector({ frm: frm, @@ -1111,6 +1115,7 @@ erpnext.show_serial_batch_selector = function(frm, d) { type: "Warehouse", name: d.warehouse }, - }); + callback: callback + }, show_dialog); }); } 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 0e6ecdd7d00..354cdea1c29 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -139,6 +139,7 @@ class PointOfSale { update_item_in_cart(item_code, field='qty', value=1) { if(this.cart.exists(item_code)) { const item = this.frm.doc.items.find(i => i.item_code === item_code); + frappe.flags.hide_serial_batch_dialog = false; if (typeof value === 'string' && !in_list(['serial_no', 'batch_no'], field)) { // value can be of type '+1' or '-1' @@ -168,29 +169,28 @@ class PointOfSale { // add to cur_frm const item = this.frm.add_child('items', args); + frappe.flags.hide_serial_batch_dialog = true; this.frm.script_manager .trigger('item_code', item.doctype, item.name) .then(() => { - // update cart - this.update_cart_data(item); + const show_dialog = item.has_serial_no || item.has_batch_no; + if (show_dialog && field == 'qty') { + // check has serial no/batch no and update cart + this.select_batch_and_serial_no(item); + } else { + // update cart + this.update_cart_data(item); + } }); } select_batch_and_serial_no(item) { - new erpnext.SerialNoBatchSelector({ - frm: this.frm, - item: item, - warehouse_details: { - type: "Warehouse", - name: item.warehouse - }, - callback: (item) => { - this.update_item_in_frm(item) - .then(() => { - // update cart - this.update_cart_data(item); - }); - } + erpnext.show_serial_batch_selector(this.frm, item, () => { + this.update_item_in_frm(item) + .then(() => { + // update cart + this.update_cart_data(item); + }); }, true); } @@ -308,7 +308,6 @@ class PointOfSale { frm.doc.items = []; frm.set_value('is_pos', 1); frm.meta.default_print_format = 'POS Invoice'; - return frm; } } @@ -340,6 +339,9 @@ class PointOfSale { if(this.frm.doc.docstatus !== 1) return; this.page.set_secondary_action(__("Print"), () => { + if (this.pos_profile && this.pos_profile.print_format_for_online) { + this.frm.meta.default_print_format = this.pos_profile.print_format_for_online; + } this.frm.print_preview.printit(true); });