unify account_id creation

This commit is contained in:
Thomas Girod
2022-11-23 12:23:17 +01:00
parent 37216cd16b
commit 751c8a8bc6
6 changed files with 81 additions and 28 deletions

View File

@ -1780,11 +1780,7 @@ def create_billing_info(request, user_id):
if user.id != user_id and not user.has_perm("counter:add_billinginfo"):
raise PermissionDenied()
user = get_object_or_404(User, pk=user_id)
if not hasattr(user, "customer"):
customer = Customer.new_for_user(user)
customer.save()
else:
customer = get_object_or_404(Customer, user_id=user_id)
customer, _ = Customer.get_or_create(user)
BillingInfo.objects.create(customer=customer)
return __manage_billing_info_req(request, user_id, True)