From f7cfd3509228e1f9c0ec7fbb8104ed96b016f7a4 Mon Sep 17 00:00:00 2001 From: Marc Lebreuil Date: Thu, 22 Aug 2024 15:12:32 +0200 Subject: [PATCH] fix invoice creation --- CHANGELOG.md | 4 +++- src/netbox_contract/forms.py | 4 ++++ src/netbox_contract/views.py | 2 +- contract_migration.py => utils/contract_migration.py | 0 4 files changed, 8 insertions(+), 2 deletions(-) rename contract_migration.py => utils/contract_migration.py (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5efd4dd..9804d26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ ### Version 2.2.3 -* Fix accounting dimensions access through Dynamic Object Fields +* Fix accounting dimensions access through Dynamic Object Fields +* Fix invoice creation from contract. +* Add scripts to convert accounting dimensions in the json fields of contract and invoices to invoice template, invoicelines and dimensions objects. ### Version 2.2.2 diff --git a/src/netbox_contract/forms.py b/src/netbox_contract/forms.py index 2de9ff0..eea70e8 100644 --- a/src/netbox_contract/forms.py +++ b/src/netbox_contract/forms.py @@ -241,6 +241,10 @@ class ContractBulkEditForm(NetBoxModelBulkEditForm): class InvoiceForm(NetBoxModelForm): + number = forms.CharField( + max_length=100, + help_text='Invoice template name will be overriden to _invoice_template_contract name', + ) contracts = DynamicModelMultipleChoiceField( queryset=Contract.objects.all(), required=False ) diff --git a/src/netbox_contract/views.py b/src/netbox_contract/views.py index caef4f8..8638f0d 100644 --- a/src/netbox_contract/views.py +++ b/src/netbox_contract/views.py @@ -278,7 +278,7 @@ def get(self, request, *args, **kwargs): contract = Contract.objects.get(pk=initial_data['contracts']) try: - last_invoice = contract.invoices.filter(template=False).latest( + last_invoice = contract.invoices.exclude(template=True).latest( 'period_end' ) new_period_start = last_invoice.period_end + timedelta(days=1) diff --git a/contract_migration.py b/utils/contract_migration.py similarity index 100% rename from contract_migration.py rename to utils/contract_migration.py