[pos] [minor] added pos in sales order for testing

This commit is contained in:
Akhilesh Darjee
2013-09-17 11:56:17 +05:30
parent 4a0cae8b41
commit 6773bc2512
4 changed files with 95 additions and 48 deletions

View File

@@ -82,10 +82,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
cur_frm.cscript.sales_order_btn(); cur_frm.cscript.sales_order_btn();
cur_frm.cscript.delivery_note_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() { sales_order_btn: function() {
@@ -125,53 +121,53 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
}); });
}, },
pos_btn: function() { // pos_btn: function() {
if(cur_frm.$pos_btn) // if(cur_frm.$pos_btn)
cur_frm.$pos_btn.remove(); // cur_frm.$pos_btn.remove();
if(!cur_frm.pos_active) { // if(!cur_frm.pos_active) {
var btn_label = wn._("POS View"), // var btn_label = wn._("POS View"),
icon = "icon-desktop"; // icon = "icon-desktop";
cur_frm.cscript.sales_order_btn(); // cur_frm.cscript.sales_order_btn();
cur_frm.cscript.delivery_note_btn(); // cur_frm.cscript.delivery_note_btn();
} else { // } else {
var btn_label = wn._("Invoice View"), // var btn_label = wn._("Invoice View"),
icon = "icon-file-text"; // icon = "icon-file-text";
if (cur_frm.doc.docstatus===0) { // if (cur_frm.doc.docstatus===0) {
this.$delivery_note_btn.remove(); // this.$delivery_note_btn.remove();
this.$sales_order_btn.remove(); // this.$sales_order_btn.remove();
} // }
} // }
cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() { // cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() {
cur_frm.cscript.toggle_pos(); // cur_frm.cscript.toggle_pos();
cur_frm.cscript.pos_btn(); // cur_frm.cscript.pos_btn();
}, icon); // }, icon);
}, // },
toggle_pos: function(show) { // toggle_pos: function(show) {
if (!this.frm.doc.selling_price_list) // if (!this.frm.doc.selling_price_list)
msgprint(wn._("Please select Price List")) // msgprint(wn._("Please select Price List"))
else { // else {
if((show===true && cur_frm.pos_active) || (show===false && !cur_frm.pos_active)) return; // if((show===true && cur_frm.pos_active) || (show===false && !cur_frm.pos_active)) return;
// make pos // // make pos
if(!cur_frm.pos) { // if(!cur_frm.pos) {
cur_frm.layout.add_view("pos"); // cur_frm.layout.add_view("pos");
cur_frm.pos = new erpnext.POS(cur_frm.layout.views.pos, cur_frm); // cur_frm.pos = new erpnext.POS(cur_frm.layout.views.pos, cur_frm);
} // }
// toggle view // // toggle view
cur_frm.layout.set_view(cur_frm.pos_active ? "" : "pos"); // cur_frm.layout.set_view(cur_frm.pos_active ? "" : "pos");
cur_frm.pos_active = !cur_frm.pos_active; // cur_frm.pos_active = !cur_frm.pos_active;
// refresh // // refresh
if(cur_frm.pos_active) // if(cur_frm.pos_active)
cur_frm.pos.refresh(); // cur_frm.pos.refresh();
} // }
}, // },
tc_name: function() { tc_name: function() {
this.get_terms(); this.get_terms();

View File

@@ -22,6 +22,6 @@ def execute():
webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling)
except MySQLdb.OperationalError, e: except MySQLdb.OperationalError, e:
if e.args[0] == 1054: 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: else:
raise e raise e

View File

@@ -62,6 +62,56 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
erpnext.hide_company(); erpnext.hide_company();
this.show_item_wise_taxes(); this.show_item_wise_taxes();
this.set_dynamic_labels(); 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() { 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)) : (this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) :
false; false;
// if(!valid_conversion_rate) { if(!valid_conversion_rate) {
// wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) + wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) +
// " 1 " + this.frm.doc.currency + " = [?] " + company_currency); " 1 " + this.frm.doc.currency + " = [?] " + company_currency);
// } }
}, },
calculate_taxes_and_totals: function() { calculate_taxes_and_totals: function() {

View File

@@ -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/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/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/utilities/doctype/sms_control/sms_control.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
refresh: function(doc, dt, dn) { refresh: function(doc, dt, dn) {