Skip to content

Commit

Permalink
Merge pull request #179 from mlebreuil/178-include-additional-fields-…
Browse files Browse the repository at this point in the history
…in-the-invoice-and-contract-filterset-class

Add filtering by invoice name and contract number
  • Loading branch information
mlebreuil authored Sep 3, 2024
2 parents b1973a8 + e70f46d commit 59a19f5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

## Version 2

### Version 2.2.5

* [178](https://github.com/mlebreuil/netbox-contract/issues/178) Add the possibility to filter on invoice number, and contract name through the API.

### Version 2.2.4

* [166](https://github.com/mlebreuil/netbox-contract/issues/166) Review the Contract view to include invoice template details and lines.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "netbox-contract"
version = "2.2.4"
version = "2.2.5"
authors = [
{ name="Marc Lebreuil", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion src/netbox_contract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ContractsConfig(PluginConfig):
name = 'netbox_contract'
verbose_name = 'Netbox contract'
description = 'Contract management plugin for Netbox'
version = '2.2.4'
version = '2.2.5'
author = 'Marc Lebreuil'
author_email = '[email protected]'
base_url = 'contracts'
Expand Down
8 changes: 6 additions & 2 deletions src/netbox_contract/filtersets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import django_filters
from django.db.models import Q
from netbox.filtersets import NetBoxModelFilterSet

Expand All @@ -8,13 +9,16 @@
Invoice,
InvoiceLine,
ServiceProvider,
StatusChoices,
)


class ContractFilterSet(NetBoxModelFilterSet):
status = django_filters.MultipleChoiceFilter(choices=StatusChoices, null_value=None)

class Meta:
model = Contract
fields = ('id', 'internal_partie', 'status', 'parent')
fields = ('id', 'name', 'internal_partie', 'external_reference', 'parent')

def search(self, queryset, name, value):
return queryset.filter(
Expand All @@ -28,7 +32,7 @@ def search(self, queryset, name, value):
class InvoiceFilterSet(NetBoxModelFilterSet):
class Meta:
model = Invoice
fields = ('id', 'contracts')
fields = ('id', 'number', 'template', 'contracts')

def search(self, queryset, name, value):
return queryset.filter(
Expand Down

0 comments on commit 59a19f5

Please sign in to comment.