From 72e1719220488a2a83cf3efb7f0c09c7a5b3c1d8 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 8 Aug 2014 15:30:49 +0530 Subject: [PATCH] added icon for pos --- erpnext/accounts/doctype/sales_invoice/pos.js | 6 +-- erpnext/accounts/page/pos/__init__.py | 0 erpnext/accounts/page/pos/pos.js | 52 +++++++++++++++++++ erpnext/accounts/page/pos/pos.json | 28 ++++++++++ erpnext/config/desktop.py | 6 +++ erpnext/public/js/transaction.js | 5 ++ 6 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 erpnext/accounts/page/pos/__init__.py create mode 100644 erpnext/accounts/page/pos/pos.js create mode 100644 erpnext/accounts/page/pos/pos.json diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/accounts/doctype/sales_invoice/pos.js index 2dcfc68a9e..843c32440e 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.js +++ b/erpnext/accounts/doctype/sales_invoice/pos.js @@ -367,10 +367,8 @@ erpnext.POS = Class.extend({ this.hide_payment_button(); // If quotation to is not Customer then remove party - if (this.frm.doctype == "Quotation") { + if (this.frm.doctype == "Quotation" && this.frm.doc.quotation_to!="Customer") { this.party_field.$wrapper.remove(); - if (this.frm.doc.quotation_to == "Customer") - this.make_party(); } }, refresh_item_list: function() { @@ -489,7 +487,7 @@ erpnext.POS = Class.extend({ if (operation == "increase-qty") this.update_qty(item_code, item_qty + 1); - else if (operation == "decrease-qty" && item_qty != 1) + else if (operation == "decrease-qty" && item_qty != 0) this.update_qty(item_code, item_qty - 1); }, disable_text_box_and_button: function() { diff --git a/erpnext/accounts/page/pos/__init__.py b/erpnext/accounts/page/pos/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js new file mode 100644 index 0000000000..0d06de1152 --- /dev/null +++ b/erpnext/accounts/page/pos/pos.js @@ -0,0 +1,52 @@ +frappe.pages['pos'].onload = function(wrapper) { + frappe.ui.make_app_page({ + parent: wrapper, + title: 'Start POS', + single_column: true + }); + + wrapper.body.html('
\ +

' + __("Select type of transaction") + '

\ +

\ +

' + + __("Please setup your POS Preferences") + + ': ' + + __("Make new POS Setting") + '

\ +

\ +
'); + + var pos_type = frappe.ui.form.make_control({ + parent: wrapper.body.find(".select-type"), + df: { + fieldtype: "Select", + options: [ + {label: __("Billing (Sales Invoice)"), value:"Sales Invoice"}, + {value:"Sales Order"}, + {value:"Delivery Note"}, + {value:"Quotation"}, + {value:"Purchase Order"}, + {value:"Purchase Receipt"}, + {value:"Purchase Invoice"}, + ], + fieldname: "pos_type" + }, + only_input: true + }); + + pos_type.refresh(); + + wrapper.body.find(".btn-primary").on("click", function() { + erpnext.open_as_pos = true; + new_doc(pos_type.get_value()); + }); + + $.ajax({ + url: "/api/resource/POS Setting", + success: function(data) { + if(!data.data.length) { + wrapper.body.find(".pos-setting-message").removeClass('hide'); + } + } + }) + +} diff --git a/erpnext/accounts/page/pos/pos.json b/erpnext/accounts/page/pos/pos.json new file mode 100644 index 0000000000..31c043c84e --- /dev/null +++ b/erpnext/accounts/page/pos/pos.json @@ -0,0 +1,28 @@ +{ + "content": null, + "creation": "2014-08-08 02:45:55.931022", + "docstatus": 0, + "doctype": "Page", + "icon": "icon-th", + "modified": "2014-08-08 05:59:33.045012", + "modified_by": "Administrator", + "module": "Accounts", + "name": "pos", + "owner": "Administrator", + "page_name": "pos", + "roles": [ + { + "role": "Sales User" + }, + { + "role": "Purchase User" + }, + { + "role": "Accounts User" + } + ], + "script": null, + "standard": "Yes", + "style": null, + "title": "POS" +} \ No newline at end of file diff --git a/erpnext/config/desktop.py b/erpnext/config/desktop.py index 4b9f8f8a66..9f40ef33ab 100644 --- a/erpnext/config/desktop.py +++ b/erpnext/config/desktop.py @@ -38,6 +38,12 @@ def get_data(): "link": "List/Note", "type": "list" }, + "POS": { + "color": "#589494", + "icon": "icon-th", + "type": "page", + "link": "pos" + }, "Projects": { "color": "#8e44ad", "icon": "icon-puzzle-piece", diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 8a9be1d935..44835ce04d 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -74,6 +74,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.$pos_btn = this.frm.appframe.add_primary_action(btn_label, function() { me.toggle_pos(); }, icon, "btn-default"); + + if(erpnext.open_as_pos) { + me.toggle_pos(true); + erpnext.open_as_pos = false; + } }, toggle_pos: function(show) {