create customer from POS
This commit is contained in:
parent
8c9c9cfc5f
commit
fe7a5b305f
@ -41,6 +41,7 @@ def get_pos_data():
|
|||||||
'pos_profile': pos_profile,
|
'pos_profile': pos_profile,
|
||||||
'meta': {
|
'meta': {
|
||||||
'invoice': frappe.get_meta('Sales Invoice'),
|
'invoice': frappe.get_meta('Sales Invoice'),
|
||||||
|
'customer': frappe.get_meta('Customer'),
|
||||||
'items': frappe.get_meta('Sales Invoice Item'),
|
'items': frappe.get_meta('Sales Invoice Item'),
|
||||||
'taxes': frappe.get_meta('Sales Taxes and Charges')
|
'taxes': frappe.get_meta('Sales Taxes and Charges')
|
||||||
}
|
}
|
||||||
|
@ -325,6 +325,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
|
|
||||||
$.each(this.meta, function(i, data){
|
$.each(this.meta, function(i, data){
|
||||||
frappe.meta.sync(data)
|
frappe.meta.sync(data)
|
||||||
|
locals["DocType"][data.name] = data;
|
||||||
})
|
})
|
||||||
|
|
||||||
this.print_template_data = frappe.render_template("print_template",
|
this.print_template_data = frappe.render_template("print_template",
|
||||||
@ -412,21 +413,26 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
source: function (request, response) {
|
source: function (request, response) {
|
||||||
me.customer_data = me.get_customers(request.term)
|
me.customer_data = me.get_customers(request.term)
|
||||||
|
me.add_customer();
|
||||||
|
|
||||||
response($.map(me.customer_data, function(data){
|
response($.map(me.customer_data, function(data){
|
||||||
return {label: data.name, value: data.name,
|
return {label: data.name, customer_name: data.name, customer_group: data.customer_group,
|
||||||
customer_group: data.customer_group, territory: data.territory}
|
territory: data.territory, onclick: data.onclick}
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
change: function(event, ui){
|
select: function(event, ui){
|
||||||
if(ui.item){
|
if(ui.item.onclick) {
|
||||||
me.frm.doc.customer = ui.item.label;
|
ui.item.value = ""
|
||||||
me.frm.doc.customer_name = ui.item.customer_name;
|
ui.item.onclick(me);
|
||||||
me.frm.doc.customer_group = ui.item.customer_group;
|
}else if(ui.item) {
|
||||||
me.frm.doc.territory = ui.item.territory;
|
me.update_customer_data(ui.item)
|
||||||
}else{
|
|
||||||
me.frm.doc.customer = me.party_field.$input.val();
|
|
||||||
}
|
}
|
||||||
me.refresh();
|
me.refresh();
|
||||||
|
},
|
||||||
|
change: function(event, ui) {
|
||||||
|
if(!ui.item) {
|
||||||
|
me.frm.doc.customer = $(this).val();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).on("focus", function(){
|
}).on("focus", function(){
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
@ -434,7 +440,43 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
me.party_field.$input.autocomplete( "search", " " );
|
me.party_field.$input.autocomplete( "search", " " );
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
}).autocomplete(this.party_field).data('ui-autocomplete')._renderItem = function(ul, d){
|
||||||
|
var html = "<span>" + __(d.label) + "</span>";
|
||||||
|
return $('<li></li>')
|
||||||
|
.data('item.autocomplete', d)
|
||||||
|
.html('<a><p>' + html + '</p></a>')
|
||||||
|
.appendTo(ul);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
add_customer: function() {
|
||||||
|
var me = this;
|
||||||
|
if(this.connection_status) {
|
||||||
|
this.customer_data.push({
|
||||||
|
name: "<span class='text-primary link-option'>"
|
||||||
|
+ "<i class='fa fa-plus' style='margin-right: 5px;'></i> "
|
||||||
|
+ __("Create a new Customer")
|
||||||
|
+ "</span>",
|
||||||
|
onclick: me.new_customer
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
new_customer: function(obj) {
|
||||||
|
var me = obj;
|
||||||
|
frappe.ui.form.quick_entry('Customer', function(doc){
|
||||||
|
me.customers.push(doc)
|
||||||
|
me.party_field.$input.val(doc.name);
|
||||||
|
me.update_customer_data(doc)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
update_customer_data: function(doc) {
|
||||||
|
var me = this;
|
||||||
|
this.frm.doc.customer = doc.label || doc.name;
|
||||||
|
this.frm.doc.customer_name = doc.customer_name;
|
||||||
|
this.frm.doc.customer_group = doc.customer_group;
|
||||||
|
this.frm.doc.territory = doc.territory;
|
||||||
},
|
},
|
||||||
|
|
||||||
get_customers: function(key){
|
get_customers: function(key){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user