From 8ce798426ae0449e0dfa33fa1f180cf7c8e37252 Mon Sep 17 00:00:00 2001 From: Mufti Arfan Farooqi Date: Wed, 26 Jul 2017 00:29:36 +0530 Subject: [PATCH 1/2] Fix :Customer ID being retained in customer_ID When you create an invoice, and enter a customer name, the input fetches the customers in Database. Which is then using jquery put into a hidden field "Customer_ID" in invoice form. So in case user decides he wants to create a new customer from the form, he erases the selected customer name from customer field, but the customer_ID is retained in the hidden input field. This can be fixed by adding the following code in the invoice_form.tpl to remove the old fetched customer ID in the customer_id input field. --- upload/admin/view/template/billing/invoice_form.tpl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/upload/admin/view/template/billing/invoice_form.tpl b/upload/admin/view/template/billing/invoice_form.tpl index 8affdfd..0a1ab7b 100644 --- a/upload/admin/view/template/billing/invoice_form.tpl +++ b/upload/admin/view/template/billing/invoice_form.tpl @@ -268,7 +268,9 @@ $(document).ready(function () { $('.date').datetimepicker({ format: 'YYYY-MM-DD' }); - +$("#input-customer").bind("change paste keyup", function() { + $('input[name=\'customer_id\']').val(''); +}); $('#input-customer').autocomplete({ 'source': function (request, response) { $.ajax({ @@ -652,4 +654,4 @@ function itemAutocomplete(item_row) { }); } //--> - \ No newline at end of file + From 2fcbbc1ef247d2ff75222406318c73e2932325a8 Mon Sep 17 00:00:00 2001 From: Mufti Arfan Farooqi Date: Wed, 26 Jul 2017 13:26:03 +0530 Subject: [PATCH 2/2] Remove email value from email field Since the model actually checks Email field when figuring out whether to add new customer or not, I have updated the code to remove the value from the email input field as well, otherwise there is no point in just removing the value from customer_id. --- upload/admin/view/template/billing/invoice_form.tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/upload/admin/view/template/billing/invoice_form.tpl b/upload/admin/view/template/billing/invoice_form.tpl index 0a1ab7b..66028d4 100644 --- a/upload/admin/view/template/billing/invoice_form.tpl +++ b/upload/admin/view/template/billing/invoice_form.tpl @@ -270,6 +270,8 @@ $(document).ready(function () { }); $("#input-customer").bind("change paste keyup", function() { $('input[name=\'customer_id\']').val(''); + $('input[name=\'email\']').val(''); + }); $('#input-customer').autocomplete({ 'source': function (request, response) {