[sales_invoice] [pos] [minor] Added view for POS

This commit is contained in:
Rushabh Mehta 2013-07-29 15:31:11 +05:30
parent c7280b4973
commit 4a008f5567
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,57 @@
erpnext.POS = Class.extend({
init: function(wrapper, frm) {
this.wrapper = wrapper;
this.frm = frm;
this.wrapper.html('<div class="customer-area"></div>\
<div class="item-area"></div>\
<div><button class="btn btn-default btn-add">Add</button>');
this.make();
var me = this;
$(this.frm.wrapper).on("refresh-fields", function() {
me.refresh();
});
},
make: function() {
this.make_customer();
this.make_items();
},
make_customer: function() {
var me = this;
this.customer = wn.ui.form.make_control({
df: {
"fieldtype": "Link",
"options": "Customer",
"label": "Customer",
"fieldname": "pos_customer"
},
parent: this.wrapper.find(".customer-area")
});
this.customer.make_input();
this.customer.$input.on("change", function() {
if(!me.customer.autocomplete_open)
wn.model.set_value("Sales Invoice", me.frm.docname, "customer", this.value);
});
},
make_items: function() {
var me = this;
this.wrapper.find(".btn-add").click(function() {
var child = wn.model.add_child(me.frm.doc, "Sales Invoice Item", "entries");
child.item_code = "Test Item";
me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name);
});
},
refresh: function() {
var me = this;
this.customer.set_input(this.frm.doc.customer);
// add items
var $items = me.wrapper.find(".item-area").empty();
$.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries",
"Sales Invoice"), function(i, d) {
$(repl("<div>%(item_code)s</div>", d)).appendTo($items);
});
}
})

View File

@ -25,6 +25,7 @@ cur_frm.pformat.print_heading = 'Invoice';
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/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_invoice/pos.js');
wn.provide("erpnext.accounts");
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
@ -37,6 +38,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
this.frm.set_df_property("debit_to", "print_hide", 0);
}
}
// if(this.frm.doc.is_pos && this.frm.doc.docstatus===0) {
// cur_frm.cscript.toggle_pos(true);
// }
},
refresh: function(doc, dt, dn) {
@ -96,11 +101,33 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
})
});
// cur_frm.add_custom_button(wn._("POS View"), function() {
// cur_frm.cscript.toggle_pos();
// }, 'icon-desktop');
}
cur_frm.cscript.hide_fields(doc, dt, dn);
},
toggle_pos: function(show) {
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);
}
// 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();
},
tc_name: function() {
this.get_terms();
},