From 6773bc251273855b5352c332116c13e68c0e8847 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 17 Sep 2013 11:56:17 +0530 Subject: [PATCH] [pos] [minor] added pos in sales order for testing --- .../doctype/sales_invoice/sales_invoice.js | 82 +++++++++---------- .../p03_buying_selling_for_price_list.py | 2 +- public/js/transaction.js | 58 ++++++++++++- selling/doctype/sales_order/sales_order.js | 1 + 4 files changed, 95 insertions(+), 48 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 60f73b5a19..73958fb672 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -82,10 +82,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.cscript.sales_order_btn(); cur_frm.cscript.delivery_note_btn(); } - - // Show POS button only if it enabled from features setup - if(cint(sys_defaults.fs_pos_view)===1) - cur_frm.cscript.pos_btn(); }, sales_order_btn: function() { @@ -125,53 +121,53 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }); }, - pos_btn: function() { - if(cur_frm.$pos_btn) - cur_frm.$pos_btn.remove(); + // pos_btn: function() { + // if(cur_frm.$pos_btn) + // cur_frm.$pos_btn.remove(); - if(!cur_frm.pos_active) { - var btn_label = wn._("POS View"), - icon = "icon-desktop"; + // if(!cur_frm.pos_active) { + // var btn_label = wn._("POS View"), + // icon = "icon-desktop"; - cur_frm.cscript.sales_order_btn(); - cur_frm.cscript.delivery_note_btn(); - } else { - var btn_label = wn._("Invoice View"), - icon = "icon-file-text"; + // cur_frm.cscript.sales_order_btn(); + // cur_frm.cscript.delivery_note_btn(); + // } else { + // var btn_label = wn._("Invoice View"), + // icon = "icon-file-text"; - if (cur_frm.doc.docstatus===0) { - this.$delivery_note_btn.remove(); - this.$sales_order_btn.remove(); - } - } + // if (cur_frm.doc.docstatus===0) { + // this.$delivery_note_btn.remove(); + // this.$sales_order_btn.remove(); + // } + // } - cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() { - cur_frm.cscript.toggle_pos(); - cur_frm.cscript.pos_btn(); - }, icon); - }, + // cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() { + // cur_frm.cscript.toggle_pos(); + // cur_frm.cscript.pos_btn(); + // }, icon); + // }, - toggle_pos: function(show) { - if (!this.frm.doc.selling_price_list) - msgprint(wn._("Please select Price List")) - else { - if((show===true && cur_frm.pos_active) || (show===false && !cur_frm.pos_active)) return; + // toggle_pos: function(show) { + // if (!this.frm.doc.selling_price_list) + // msgprint(wn._("Please select Price List")) + // else { + // if((show===true && cur_frm.pos_active) || (show===false && !cur_frm.pos_active)) return; - // make pos - if(!cur_frm.pos) { - cur_frm.layout.add_view("pos"); - cur_frm.pos = new erpnext.POS(cur_frm.layout.views.pos, cur_frm); - } + // // make pos + // if(!cur_frm.pos) { + // cur_frm.layout.add_view("pos"); + // cur_frm.pos = new erpnext.POS(cur_frm.layout.views.pos, cur_frm); + // } - // toggle view - cur_frm.layout.set_view(cur_frm.pos_active ? "" : "pos"); - cur_frm.pos_active = !cur_frm.pos_active; + // // toggle view + // cur_frm.layout.set_view(cur_frm.pos_active ? "" : "pos"); + // cur_frm.pos_active = !cur_frm.pos_active; - // refresh - if(cur_frm.pos_active) - cur_frm.pos.refresh(); - } - }, + // // refresh + // if(cur_frm.pos_active) + // cur_frm.pos.refresh(); + // } + // }, tc_name: function() { this.get_terms(); diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py index c251712437..7d222c8e8a 100644 --- a/patches/june_2013/p03_buying_selling_for_price_list.py +++ b/patches/june_2013/p03_buying_selling_for_price_list.py @@ -22,6 +22,6 @@ def execute(): webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) except MySQLdb.OperationalError, e: if e.args[0] == 1054: - webnotes.conn.set_value("Price List", price_list, "buying_or_selling", "Selling") + webnotes.conn.sql("""update `tabItem Price` set buying_or_selling='Selling' """) else: raise e \ No newline at end of file diff --git a/public/js/transaction.js b/public/js/transaction.js index 387140472c..f7caded328 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -62,6 +62,56 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ erpnext.hide_company(); this.show_item_wise_taxes(); this.set_dynamic_labels(); + + // Show POS button only if it is enabled from features setup + if(cint(sys_defaults.fs_pos_view)===1 && this.frm.doctype!="Material Request") + this.pos_btn(); + }, + + pos_btn: function() { + if(this.$pos_btn) + this.$pos_btn.remove(); + + if(!this.pos_active) { + var btn_label = wn._("POS View"), + icon = "icon-desktop"; + } else { + var btn_label = wn._(this.frm.doctype) + wn._(" View"), + icon = "icon-file-text"; + + + if (this.frm.doc.docstatus===0) { + this.frm.clear_custom_buttons(); + } + } + var me = this; + + this.$pos_btn = this.frm.add_custom_button(btn_label, function() { + me.toggle_pos(); + me.pos_btn(); + }, icon); + }, + + toggle_pos: function(show) { + if (!this.frm.doc.selling_price_list) + msgprint(wn._("Please select Price List")) + else { + if((show===true && this.pos_active) || (show===false && !this.pos_active)) return; + + // make pos + if(!this.pos) { + this.frm.layout.add_view("pos"); + this.frm.pos = new erpnext.POS(this.frm.layout.views.pos, this.frm); + } + + // toggle view + this.frm.layout.set_view(this.pos_active ? "" : "pos"); + this.pos_active = !this.pos_active; + + // refresh + if(this.pos_active) + this.frm.pos.refresh(); + } }, validate: function() { @@ -418,10 +468,10 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ (this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) : false; - // if(!valid_conversion_rate) { - // wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) + - // " 1 " + this.frm.doc.currency + " = [?] " + company_currency); - // } + if(!valid_conversion_rate) { + wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) + + " 1 " + this.frm.doc.currency + " = [?] " + company_currency); + } }, calculate_taxes_and_totals: function() { diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js index 33699f05d8..161e10fe4e 100644 --- a/selling/doctype/sales_order/sales_order.js +++ b/selling/doctype/sales_order/sales_order.js @@ -12,6 +12,7 @@ cur_frm.cscript.sales_team_fname = "sales_team"; wn.require('app/selling/doctype/sales_common/sales_common.js'); wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); +wn.require('app/accounts/doctype/sales_invoice/pos.js'); erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({ refresh: function(doc, dt, dn) {