diff --git a/backend/views/core/clients/create.py b/backend/views/core/clients/create.py index fa60fb3f..01c1f2fc 100644 --- a/backend/views/core/clients/create.py +++ b/backend/views/core/clients/create.py @@ -36,12 +36,9 @@ def create_client(request: HtmxHttpRequest): def create_client_instance(user, client_details): - kwargs = {"organization": user.logged_in_as_team} if user.logged_in_as_team else {"user": user} + organization = user.logged_in_as_team if user.logged_in_as_team else None try: - client = Client.objects.create(**kwargs) - for model_field, new_value in client_details.items(): - setattr(client, model_field, new_value) - client.save() + client = Client.objects.create(organization=organization, **client_details) return client except Exception as e: print(f"Failed to create client: {e}") diff --git a/backend/views/core/invoices/edit.py b/backend/views/core/invoices/edit.py index befe045a..f2872f55 100644 --- a/backend/views/core/invoices/edit.py +++ b/backend/views/core/invoices/edit.py @@ -35,7 +35,7 @@ def invoice_get_existing_data(invoice_obj): stored_data.update({ "to_name": client_to.name, "to_company": client_to.company, - "is_represntative": client_to.representative, + "is_representative": client_to.representative, # "to_address": client_to.address, # "to_city": client_to.city, # "to_county": client_to.county, diff --git a/backend/views/core/invoices/view.py b/backend/views/core/invoices/view.py index 3d5aec14..68384e17 100644 --- a/backend/views/core/invoices/view.py +++ b/backend/views/core/invoices/view.py @@ -2,13 +2,10 @@ from django.contrib import messages from django.contrib.auth.models import AnonymousUser -from django.shortcuts import redirect -from django.shortcuts import render +from django.shortcuts import redirect, render from login_required import login_not_required -from backend.models import Invoice -from backend.models import InvoiceURL -from backend.models import UserSettings +from backend.models import Invoice, InvoiceURL, UserSettings def preview(request, invoice_id):