[fix] customer edit and numeric keypad visibility issue in the pos
This commit is contained in:
parent
6ee91ec9c6
commit
b719dc53fc
@ -170,6 +170,9 @@ def get_customers_list(pos_profile):
|
|||||||
|
|
||||||
def get_customers_address(customers):
|
def get_customers_address(customers):
|
||||||
customer_address = {}
|
customer_address = {}
|
||||||
|
if isinstance(customers, basestring):
|
||||||
|
customers = [frappe._dict({'name': customers})]
|
||||||
|
|
||||||
for data in customers:
|
for data in customers:
|
||||||
address = frappe.db.sql(""" select name, address_line1, address_line2, city, state,
|
address = frappe.db.sql(""" select name, address_line1, address_line2, city, state,
|
||||||
email_id, phone, fax, pincode from `tabAddress` where is_primary_address =1 and name in
|
email_id, phone, fax, pincode from `tabAddress` where is_primary_address =1 and name in
|
||||||
@ -292,6 +295,7 @@ def make_invoice(doc_list={}, email_queue_list={}, customers_list={}):
|
|||||||
if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}):
|
if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}):
|
||||||
validate_records(doc)
|
validate_records(doc)
|
||||||
si_doc = frappe.new_doc('Sales Invoice')
|
si_doc = frappe.new_doc('Sales Invoice')
|
||||||
|
si_doc.due_date = doc.get('posting_date')
|
||||||
si_doc.offline_pos_name = name
|
si_doc.offline_pos_name = name
|
||||||
si_doc.update(doc)
|
si_doc.update(doc)
|
||||||
submit_invoice(si_doc, name, doc)
|
submit_invoice(si_doc, name, doc)
|
||||||
@ -328,10 +332,16 @@ def add_customer(name):
|
|||||||
customer_doc.flags.ignore_mandatory = True
|
customer_doc.flags.ignore_mandatory = True
|
||||||
customer_doc.save(ignore_permissions = True)
|
customer_doc.save(ignore_permissions = True)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
return customer_doc.name
|
||||||
|
|
||||||
def make_address(args, customer):
|
def make_address(args, customer):
|
||||||
if args.get('name'):
|
if not args.get('address_line1'): return
|
||||||
address = frappe.get_doc('Address', args.get('name'))
|
|
||||||
|
name = args.get('name') or get_customers_address(customer)[customer].get("name")
|
||||||
|
|
||||||
|
if name:
|
||||||
|
address = frappe.get_doc('Address', name)
|
||||||
|
frappe.errprint(address)
|
||||||
else:
|
else:
|
||||||
address = frappe.new_doc('Address')
|
address = frappe.new_doc('Address')
|
||||||
address.country = frappe.db.get_value('Company', args.get('company'), 'country')
|
address.country = frappe.db.get_value('Company', args.get('company'), 'country')
|
||||||
|
|||||||
@ -475,6 +475,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
this.pos_bill = this.wrapper.find('.pos-bill-wrapper').hide();
|
this.pos_bill = this.wrapper.find('.pos-bill-wrapper').hide();
|
||||||
this.list_customers = this.wrapper.find('.list-customers');
|
this.list_customers = this.wrapper.find('.list-customers');
|
||||||
this.numeric_keypad = this.wrapper.find('.numeric_keypad');
|
this.numeric_keypad = this.wrapper.find('.numeric_keypad');
|
||||||
|
this.list_customers_btn.addClass("view_customer")
|
||||||
|
|
||||||
me.render_list_customers();
|
me.render_list_customers();
|
||||||
me.toggle_totals_area(false);
|
me.toggle_totals_area(false);
|
||||||
@ -495,10 +496,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
me.toggle_totals_area(false);
|
me.toggle_totals_area(false);
|
||||||
me.toggle_delete_button()
|
me.toggle_delete_button()
|
||||||
me.list_customers.hide();
|
me.list_customers.hide();
|
||||||
if(me.frm.doc.items.length > 0) {
|
|
||||||
me.numeric_keypad.show();
|
me.numeric_keypad.show();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.add_customer_btn.on('click', function() {
|
this.add_customer_btn.on('click', function() {
|
||||||
me.save_previous_entry();
|
me.save_previous_entry();
|
||||||
@ -694,7 +693,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
.get(0);
|
.get(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var customers = this.customers.map(function (c) {
|
|
||||||
|
this.customers_mapper = this.customers.map(function (c) {
|
||||||
return {
|
return {
|
||||||
label: c.name,
|
label: c.name,
|
||||||
value: c.name,
|
value: c.name,
|
||||||
@ -703,7 +703,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
customers.push({
|
this.customers_mapper.push({
|
||||||
label: "<span class='text-primary link-option'>"
|
label: "<span class='text-primary link-option'>"
|
||||||
+ "<i class='fa fa-plus' style='margin-right: 5px;'></i> "
|
+ "<i class='fa fa-plus' style='margin-right: 5px;'></i> "
|
||||||
+ __("Create a new Customer")
|
+ __("Create a new Customer")
|
||||||
@ -711,11 +711,11 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
value: 'is_action',
|
value: 'is_action',
|
||||||
action: me.add_customer
|
action: me.add_customer
|
||||||
});
|
});
|
||||||
this.party_field.awesomeplete.list = customers;
|
this.autocomplete_customers();
|
||||||
|
|
||||||
this.party_field.$input
|
this.party_field.$input
|
||||||
.on('input', function (e) {
|
.on('input', function (e) {
|
||||||
me.party_field.awesomeplete.list = customers;
|
me.party_field.awesomeplete.list = this.customers_mapper;
|
||||||
})
|
})
|
||||||
.on('awesomplete-select', function (e) {
|
.on('awesomplete-select', function (e) {
|
||||||
var customer = me.party_field.awesomeplete
|
var customer = me.party_field.awesomeplete
|
||||||
@ -731,6 +731,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
me.update_customer_data(customer);
|
me.update_customer_data(customer);
|
||||||
me.refresh();
|
me.refresh();
|
||||||
me.set_focus();
|
me.set_focus();
|
||||||
|
me.list_customers_btn.removeClass("view_customer");
|
||||||
})
|
})
|
||||||
.on('focus', function (e) {
|
.on('focus', function (e) {
|
||||||
$(e.target).val('').trigger('input');
|
$(e.target).val('').trigger('input');
|
||||||
@ -754,6 +755,10 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
autocomplete_customers: function() {
|
||||||
|
this.party_field.awesomeplete.list = this.customers_mapper;
|
||||||
|
},
|
||||||
|
|
||||||
toggle_edit_button: function(flag) {
|
toggle_edit_button: function(flag) {
|
||||||
this.page.wrapper.find('.edit-customer-btn').toggle(flag);
|
this.page.wrapper.find('.edit-customer-btn').toggle(flag);
|
||||||
},
|
},
|
||||||
@ -768,10 +773,10 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
|
|
||||||
add_customer: function() {
|
add_customer: function() {
|
||||||
this.frm.doc.customer = "";
|
this.frm.doc.customer = "";
|
||||||
this.update_customer()
|
this.update_customer(true)
|
||||||
},
|
},
|
||||||
|
|
||||||
update_customer: function () {
|
update_customer: function (new_customer) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (!this.connection_status) return;
|
if (!this.connection_status) return;
|
||||||
|
|
||||||
@ -844,14 +849,14 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
this.render_address_data()
|
this.render_address_data()
|
||||||
|
|
||||||
this.customer_doc.set_primary_action(__("Save"), function () {
|
this.customer_doc.set_primary_action(__("Save"), function () {
|
||||||
me.make_offline_customer();
|
me.make_offline_customer(new_customer);
|
||||||
me.pos_bill.show();
|
me.pos_bill.show();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render_address_data: function() {
|
render_address_data: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.address_data = this.address[this.frm.doc.customer] || this.get_address_from_localstorage();
|
this.address_data = this.address[this.frm.doc.customer];
|
||||||
this.customer_doc.set_values(this.address_data)
|
this.customer_doc.set_values(this.address_data)
|
||||||
|
|
||||||
if(!this.customer_doc.fields_dict.full_name.$input.val()) {
|
if(!this.customer_doc.fields_dict.full_name.$input.val()) {
|
||||||
@ -864,20 +869,32 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
return this.address_details[this.frm.doc.customer]
|
return this.address_details[this.frm.doc.customer]
|
||||||
},
|
},
|
||||||
|
|
||||||
make_offline_customer: function() {
|
make_offline_customer: function(new_customer) {
|
||||||
this.frm.doc.customer = this.frm.doc.customer || this.customer_doc.get_values().full_name;
|
this.frm.doc.customer = this.frm.doc.customer || this.customer_doc.get_values().full_name;
|
||||||
this.customer_details = this.get_customers_details();
|
this.customer_details = this.get_customers_details();
|
||||||
this.customer_details[this.frm.doc.customer] = this.get_prompt_details();
|
this.customer_details[this.frm.doc.customer] = this.get_prompt_details();
|
||||||
this.party_field.$input.val(this.frm.doc.customer);
|
this.party_field.$input.val(this.frm.doc.customer);
|
||||||
this.customers.push({
|
this.update_address_and_customer_list(new_customer)
|
||||||
name: this.frm.doc.customer,
|
this.autocomplete_customers();
|
||||||
customer_name: this.frm.doc.customer
|
|
||||||
});
|
|
||||||
this.update_customer_in_localstorage()
|
this.update_customer_in_localstorage()
|
||||||
this.update_customer_in_localstorage()
|
this.update_customer_in_localstorage()
|
||||||
this.customer_doc.hide()
|
this.customer_doc.hide()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
update_address_and_customer_list: function(new_customer) {
|
||||||
|
var me = this;
|
||||||
|
if(new_customer) {
|
||||||
|
this.customers_mapper.push({
|
||||||
|
label: this.frm.doc.customer,
|
||||||
|
value: this.frm.doc.customer,
|
||||||
|
customer_group: "",
|
||||||
|
territory: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.address[this.frm.doc.customer] = this.customer_doc.get_values();
|
||||||
|
},
|
||||||
|
|
||||||
get_prompt_details: function() {
|
get_prompt_details: function() {
|
||||||
this.prompt_details = this.customer_doc.get_values();
|
this.prompt_details = this.customer_doc.get_values();
|
||||||
this.prompt_details['country'] = this.pos_profile_data.country;
|
this.prompt_details['country'] = this.pos_profile_data.country;
|
||||||
@ -1072,7 +1089,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
// if form is local then allow this function
|
// if form is local then allow this function
|
||||||
// $(me.wrapper).find(".pos-item-wrapper").on("click", function () {
|
// $(me.wrapper).find(".pos-item-wrapper").on("click", function () {
|
||||||
$(this.wrapper).on("click", ".pos-item-wrapper", function () {
|
$(this.wrapper).on("click", ".pos-item-wrapper", function () {
|
||||||
if(me.list_customers_btn.hasClass("view_customer")) return;
|
if($(me.pos_bill).is(":hidden")) return;
|
||||||
|
|
||||||
me.customer_validate();
|
me.customer_validate();
|
||||||
if (me.frm.doc.docstatus == 0) {
|
if (me.frm.doc.docstatus == 0) {
|
||||||
@ -1221,7 +1238,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
|
|
||||||
customer_validate: function () {
|
customer_validate: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (!this.frm.doc.customer) {
|
if (!this.frm.doc.customer || this.party_field.get_value() == "") {
|
||||||
frappe.throw(__("Please select customer"))
|
frappe.throw(__("Please select customer"))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1458,6 +1475,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
sn = data.serial_no.split('\n')
|
sn = data.serial_no.split('\n')
|
||||||
if(sn.length) {
|
if(sn.length) {
|
||||||
serial_no_list = me.serial_no_data[data.item_code]
|
serial_no_list = me.serial_no_data[data.item_code]
|
||||||
|
if(serial_no_list) {
|
||||||
$.each(sn, function(i, serial_no) {
|
$.each(sn, function(i, serial_no) {
|
||||||
if(in_list(Object.keys(serial_no_list), serial_no)) {
|
if(in_list(Object.keys(serial_no_list), serial_no)) {
|
||||||
delete serial_no_list[serial_no]
|
delete serial_no_list[serial_no]
|
||||||
@ -1465,6 +1483,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
})
|
})
|
||||||
me.serial_no_data[data.item_code] = serial_no_list;
|
me.serial_no_data[data.item_code] = serial_no_list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user