From 8f2bd568db7ff8e0e07029044447ae36a4ee51fc Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 31 Dec 2019 22:53:32 +0530 Subject: [PATCH] Restore billing address if VAT number is not valid --- hosting/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index 41a7967a..cdddec64 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -661,6 +661,8 @@ class SettingsView(LoginRequiredMixin, FormView): "VAT Number validation error: %s" % validate_result["error"], extra_tags='error' ) + billing_address = current_billing_address + billing_address.save() else: msg = _("Billing address updated successfully") messages.add_message(request, messages.SUCCESS, msg) @@ -725,7 +727,7 @@ class PaymentVMView(LoginRequiredMixin, FormView): form_class = BillingAddressForm def get_form_kwargs(self): - current_billing_address = self.request.user.billing_addresses.first() + current_billing_address = self.request.user.billing_addresses.last() form_kwargs = super(PaymentVMView, self).get_form_kwargs() if not current_billing_address: return form_kwargs