netbox-contract 2.3.1__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/CONTRIBUTING.md +17 -13
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/MANIFEST.in +2 -2
- {netbox_contract-2.3.1/src/netbox_contract.egg-info → netbox_contract-2.4.0}/PKG-INFO +22 -9
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/README.md +8 -6
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/__init__.py +2 -2
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/api/serializers.py +20 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/api/urls.py +1 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/api/views.py +6 -0
- netbox_contract-2.4.0/netbox_contract/constants.py +13 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/filtersets.py +17 -3
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/forms.py +103 -12
- netbox_contract-2.4.0/netbox_contract/locale/en/LC_MESSAGES/django.mo +0 -0
- netbox_contract-2.4.0/netbox_contract/locale/en/LC_MESSAGES/django.po +499 -0
- netbox_contract-2.4.0/netbox_contract/locale/fr/LC_MESSAGES/django.mo +0 -0
- netbox_contract-2.4.0/netbox_contract/locale/fr/LC_MESSAGES/django.po +503 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0019_auto_20230924_1813.py +1 -1
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0026_auto_20240421_1550.py +1 -1
- netbox_contract-2.4.0/netbox_contract/migrations/0040_alter_contract_currency_alter_invoice_currency_and_more.py +28 -0
- netbox_contract-2.4.0/netbox_contract/migrations/0041_contracttype_contract_contract_type.py +48 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/models.py +45 -1
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/navigation.py +17 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/search.py +10 -1
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/tables.py +35 -5
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/template_content.py +4 -4
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/netbox_contract/contract.html +6 -0
- netbox_contract-2.4.0/netbox_contract/templates/netbox_contract/contracttype.html +33 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/urls.py +67 -11
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/views.py +72 -10
- {netbox_contract-2.3.1 → netbox_contract-2.4.0/netbox_contract.egg-info}/PKG-INFO +22 -9
- netbox_contract-2.4.0/netbox_contract.egg-info/SOURCES.txt +87 -0
- netbox_contract-2.4.0/netbox_contract.egg-info/requires.txt +14 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/pyproject.toml +22 -17
- netbox_contract-2.3.1/src/netbox_contract/constants.py +0 -6
- netbox_contract-2.3.1/src/netbox_contract.egg-info/SOURCES.txt +0 -83
- netbox_contract-2.3.1/src/netbox_contract.egg-info/not-zip-safe +0 -1
- netbox_contract-2.3.1/src/netbox_contract.egg-info/requires.txt +0 -2
- netbox_contract-2.3.1/tests/__init__.py +0 -1
- netbox_contract-2.3.1/tests/test_netbox_contract.py +0 -5
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/LICENSE +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/docs/img/accounting_dimensions.png +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/docs/img/contract.png +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/docs/img/contract_linked_objects.png +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/docs/img/invoice.png +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/docs/img/invoice_line.png +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/docs/img/invoice_linked_objects.png +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/api/__init__.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0001_initial.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0002_alter_contract_circuit_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0003_alter_contract_custom_field_data_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0004_contract_currency_invoice_currency.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0005_contract_accounting_dimensions_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0006_alter_contract_circuit.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0007_invoice_date.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0008_invoice_comments.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0009_contract_external_reference.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0010_invoice_contracts.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0011_auto_20230122_2112.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0012_remove_invoice_contract.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0013_contract_documents_invoice_documents.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0014_contract_end_date.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0015_contractassignement.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0016_contract_parent.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0017_alter_contract_accounting_dimensions.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0018_contract_external_partie_object_id_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0020_alter_contract_external_partie.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0021_alter_contract_external_partie.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0022_alter_contract_internal_partie_alter_contract_parent.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0023_rename_contractassignement_contractassignment_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0024_remove_contract_external_partie.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0025_remove_contract_circuit_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0027_invoiceline.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0028_invoiceline_accounting_dimensions.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0029_remove_invoiceline_accounting_dimensions_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0030_alter_invoiceline_accounting_dimensions.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0031_contract_invoice_template_invoice_template.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0032_alter_invoice_period_end_alter_invoice_period_start_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0033_remove_contract_invoice_template.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0034_contract_yrc_alter_contract_mrc.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0035_accountingdimension_status_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0036_alter_invoiceline_accounting_dimensions.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0037_contract_notice_period_alter_contract_currency_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0038_alter_accountingdimension_options_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/0039_alter_accountingdimension_status_and_more.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/migrations/__init__.py +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/contract_assignments_bottom.html +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/contract_list_bottom.html +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/netbox_contract/accountingdimension.html +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/netbox_contract/contractassignment.html +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/netbox_contract/invoice.html +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/netbox_contract/invoiceline.html +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract/templates/netbox_contract/serviceprovider.html +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract.egg-info/dependency_links.txt +0 -0
- {netbox_contract-2.3.1/src → netbox_contract-2.4.0}/netbox_contract.egg-info/top_level.txt +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/setup.cfg +0 -0
- {netbox_contract-2.3.1 → netbox_contract-2.4.0}/setup.py +0 -0
|
@@ -20,20 +20,18 @@ and "help wanted" is open to whoever wants to implement it.
|
|
|
20
20
|
|
|
21
21
|
## Coding conventions
|
|
22
22
|
|
|
23
|
-
Netbox [Style Guide](https://docs
|
|
24
|
-
Django [Coding style](https://docs.djangoproject.com/en/
|
|
23
|
+
Netbox [Style Guide](https://netboxlabs.com/docs/netbox/en/stable/development/style-guide/)
|
|
24
|
+
Django [Coding style](https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/)
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
All files will be formated using the [black](https://black.readthedocs.io/en/stable/) auto-formatter.
|
|
28
|
-
Configuration is stored in pyproject.toml
|
|
26
|
+
## linting
|
|
29
27
|
|
|
30
|
-
[
|
|
28
|
+
The [ruff](https://docs.astral.sh/ruff/) linter is used to enforce code style. A [pre-commit hook](./getting-started.md#3-enable-pre-commit-hooks) which runs this automatically is included with NetBox. To invoke `ruff` manually, run:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
python3 -m pip install ruff
|
|
32
|
+
ruff check netbox_contract/
|
|
33
|
+
```
|
|
31
34
|
|
|
32
|
-
Linting and PEP8 style enforcement will be done with [Flake8](https://flake8.pycqa.org/en/latest/) which is a wrapper arround:
|
|
33
|
-
- PyFlakes
|
|
34
|
-
- pycodestyle
|
|
35
|
-
- Ned Batchelder’s McCabe script
|
|
36
|
-
Configuration is maintained in the .flake8 file (no support for pyproject.toml)
|
|
37
35
|
|
|
38
36
|
The pre-commit Python framework is used to simplify the managment of pre-commit hooks.
|
|
39
37
|
Config is stored in .pre-commit-config.yaml
|
|
@@ -100,7 +98,13 @@ Make sure taht at the Netbox installtion step you follow the "Option B: Clone th
|
|
|
100
98
|
|
|
101
99
|
Connect to the name or IP of the server (as defined in ALLOWED_HOSTS) on port 8000; for example, http://127.0.0.1:8000/.
|
|
102
100
|
|
|
103
|
-
9.
|
|
101
|
+
9. Run unittest
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
$ python3 netbox/netbox/manage.py test netbox_contract
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
10. Commit your changes and push your branch to GitHub:
|
|
104
108
|
|
|
105
109
|
```
|
|
106
110
|
$ git add .
|
|
@@ -108,7 +112,7 @@ Make sure taht at the Netbox installtion step you follow the "Option B: Clone th
|
|
|
108
112
|
$ git push origin name-of-your-bugfix-or-feature
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
1. Submit a pull request through the GitHub website.
|
|
112
116
|
|
|
113
117
|
## Model changes
|
|
114
118
|
|
|
@@ -9,5 +9,5 @@ recursive-exclude * *.py[co]
|
|
|
9
9
|
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
graft
|
|
13
|
-
graft
|
|
12
|
+
graft netbox_contract/templates
|
|
13
|
+
graft netbox_contract/templates/netbox_contract
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: netbox-contract
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Contract management plugin for Netbox
|
|
5
5
|
Author-email: Marc Lebreuil <marc@famillelebreuil.net>
|
|
6
6
|
Project-URL: Homepage, https://github.com/mlebreuil/netbox-contract
|
|
@@ -13,8 +13,19 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: python-dateutil
|
|
15
15
|
Requires-Dist: drf_yasg
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Requires-Dist: Django
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: check-manifest; extra == "dev"
|
|
19
|
+
Requires-Dist: mkdocs; extra == "dev"
|
|
20
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
21
|
+
Requires-Dist: ruff; extra == "dev"
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: coverage; extra == "test"
|
|
24
|
+
Requires-Dist: pytest; extra == "test"
|
|
25
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# Contract plugin
|
|
18
29
|
|
|
19
30
|
NetBox plugin to manage contracts.
|
|
20
31
|
|
|
@@ -24,11 +35,11 @@ NetBox plugin to manage contracts.
|
|
|
24
35
|
|
|
25
36
|
## Features
|
|
26
37
|
|
|
27
|
-
The
|
|
38
|
+
The plugin adds contracts and invoices model to NetBox.
|
|
28
39
|
It allows to link contract with objects.
|
|
29
40
|
And link invoice templates and invoices with contracts.
|
|
30
41
|
Invoice lines can be linked to each invoice / invoice template.
|
|
31
|
-
|
|
42
|
+
Accounting dimensions can be linked with invoice lines.
|
|
32
43
|
|
|
33
44
|
## Compatibility
|
|
34
45
|
|
|
@@ -36,6 +47,7 @@ Accounitng dimentoins can be linked with invoice lines.
|
|
|
36
47
|
|----------------|----------------|
|
|
37
48
|
| 4.1 | 2.2 |
|
|
38
49
|
| 4.2 | 2.3 |
|
|
50
|
+
| 4.3 | 2.4 |
|
|
39
51
|
|
|
40
52
|
## Installing
|
|
41
53
|
|
|
@@ -54,7 +66,7 @@ $ python3 -m pip install netbox-contract
|
|
|
54
66
|
|
|
55
67
|
### Configure NetBox
|
|
56
68
|
|
|
57
|
-
Finally, we need to configure NetBox to enable our new plugin.
|
|
69
|
+
Finally, we need to configure NetBox to enable our new plugin. In the NetBox installation directory, open `netbox/netbox/configuration.py` and locate the `PLUGINS` parameter; it should be an empty list. (If it's not yet defined, go ahead and create it.) Add the name of our plugin to this list:
|
|
58
70
|
|
|
59
71
|
```python
|
|
60
72
|
# configuration.py
|
|
@@ -65,7 +77,7 @@ PLUGINS = [
|
|
|
65
77
|
|
|
66
78
|
### Customize the plugin
|
|
67
79
|
|
|
68
|
-
The following
|
|
80
|
+
The following configuration items can be set:
|
|
69
81
|
|
|
70
82
|
```python
|
|
71
83
|
# configuration.py
|
|
@@ -96,11 +108,12 @@ The first currency will also be the default currency for contracts.
|
|
|
96
108
|
# configuration.py
|
|
97
109
|
FIELD_CHOICES = {
|
|
98
110
|
'netbox_contract.Contract.internal_partie': (
|
|
111
|
+
('default', 'Default entity', 'green'),
|
|
99
112
|
('entity1', 'Entity 1', 'green'),
|
|
100
113
|
('entity2', 'Entity 2', 'yellow'),
|
|
101
114
|
),
|
|
102
115
|
'netbox_contract.Contract.currency': (
|
|
103
|
-
('usd', 'USD'),
|
|
116
|
+
('usd', 'USD'), # 1st position is the default currency
|
|
104
117
|
('eur', 'EUR'),
|
|
105
118
|
('chf', 'CHF'),
|
|
106
119
|
('pln', 'PLN'),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Contract
|
|
1
|
+
# Contract plugin
|
|
2
2
|
|
|
3
3
|
NetBox plugin to manage contracts.
|
|
4
4
|
|
|
@@ -8,11 +8,11 @@ NetBox plugin to manage contracts.
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
The
|
|
11
|
+
The plugin adds contracts and invoices model to NetBox.
|
|
12
12
|
It allows to link contract with objects.
|
|
13
13
|
And link invoice templates and invoices with contracts.
|
|
14
14
|
Invoice lines can be linked to each invoice / invoice template.
|
|
15
|
-
|
|
15
|
+
Accounting dimensions can be linked with invoice lines.
|
|
16
16
|
|
|
17
17
|
## Compatibility
|
|
18
18
|
|
|
@@ -20,6 +20,7 @@ Accounitng dimentoins can be linked with invoice lines.
|
|
|
20
20
|
|----------------|----------------|
|
|
21
21
|
| 4.1 | 2.2 |
|
|
22
22
|
| 4.2 | 2.3 |
|
|
23
|
+
| 4.3 | 2.4 |
|
|
23
24
|
|
|
24
25
|
## Installing
|
|
25
26
|
|
|
@@ -38,7 +39,7 @@ $ python3 -m pip install netbox-contract
|
|
|
38
39
|
|
|
39
40
|
### Configure NetBox
|
|
40
41
|
|
|
41
|
-
Finally, we need to configure NetBox to enable our new plugin.
|
|
42
|
+
Finally, we need to configure NetBox to enable our new plugin. In the NetBox installation directory, open `netbox/netbox/configuration.py` and locate the `PLUGINS` parameter; it should be an empty list. (If it's not yet defined, go ahead and create it.) Add the name of our plugin to this list:
|
|
42
43
|
|
|
43
44
|
```python
|
|
44
45
|
# configuration.py
|
|
@@ -49,7 +50,7 @@ PLUGINS = [
|
|
|
49
50
|
|
|
50
51
|
### Customize the plugin
|
|
51
52
|
|
|
52
|
-
The following
|
|
53
|
+
The following configuration items can be set:
|
|
53
54
|
|
|
54
55
|
```python
|
|
55
56
|
# configuration.py
|
|
@@ -80,11 +81,12 @@ The first currency will also be the default currency for contracts.
|
|
|
80
81
|
# configuration.py
|
|
81
82
|
FIELD_CHOICES = {
|
|
82
83
|
'netbox_contract.Contract.internal_partie': (
|
|
84
|
+
('default', 'Default entity', 'green'),
|
|
83
85
|
('entity1', 'Entity 1', 'green'),
|
|
84
86
|
('entity2', 'Entity 2', 'yellow'),
|
|
85
87
|
),
|
|
86
88
|
'netbox_contract.Contract.currency': (
|
|
87
|
-
('usd', 'USD'),
|
|
89
|
+
('usd', 'USD'), # 1st position is the default currency
|
|
88
90
|
('eur', 'EUR'),
|
|
89
91
|
('chf', 'CHF'),
|
|
90
92
|
('pln', 'PLN'),
|
|
@@ -5,11 +5,11 @@ class ContractsConfig(PluginConfig):
|
|
|
5
5
|
name = 'netbox_contract'
|
|
6
6
|
verbose_name = 'Netbox contract'
|
|
7
7
|
description = 'Contract management plugin for Netbox'
|
|
8
|
-
version = '2.
|
|
8
|
+
version = '2.4.0'
|
|
9
9
|
author = 'Marc Lebreuil'
|
|
10
10
|
author_email = 'marc@famillelebreuil.net'
|
|
11
11
|
base_url = 'contracts'
|
|
12
|
-
min_version = '4.
|
|
12
|
+
min_version = '4.3.0'
|
|
13
13
|
required_settings = []
|
|
14
14
|
default_settings = {
|
|
15
15
|
'top_level_menu': False,
|
|
@@ -11,6 +11,7 @@ from ..models import (
|
|
|
11
11
|
AccountingDimension,
|
|
12
12
|
Contract,
|
|
13
13
|
ContractAssignment,
|
|
14
|
+
ContractType,
|
|
14
15
|
Invoice,
|
|
15
16
|
InvoiceLine,
|
|
16
17
|
ServiceProvider,
|
|
@@ -395,3 +396,22 @@ class AccountingDimensionSerializer(NetBoxModelSerializer):
|
|
|
395
396
|
'last_updated',
|
|
396
397
|
)
|
|
397
398
|
brief_fields = ('id', 'name', 'value', 'url', 'display')
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
class ContractTypeSerializer(NetBoxModelSerializer):
|
|
402
|
+
url = serializers.HyperlinkedIdentityField(view_name='plugins-api:netbox_contract-api:contracttype-detail')
|
|
403
|
+
|
|
404
|
+
class Meta:
|
|
405
|
+
model = ContractType
|
|
406
|
+
fields = (
|
|
407
|
+
'id',
|
|
408
|
+
'url',
|
|
409
|
+
'display',
|
|
410
|
+
'name',
|
|
411
|
+
'description',
|
|
412
|
+
'tags',
|
|
413
|
+
'custom_fields',
|
|
414
|
+
'created',
|
|
415
|
+
'last_updated',
|
|
416
|
+
)
|
|
417
|
+
brief_fields = ('id', 'name', 'description', 'url', 'display')
|
|
@@ -6,6 +6,7 @@ app_name = 'netbox_contract'
|
|
|
6
6
|
|
|
7
7
|
router = NetBoxRouter()
|
|
8
8
|
router.register('contracts', views.ContractViewSet)
|
|
9
|
+
router.register('contracttype', views.ContractTypeViewSet)
|
|
9
10
|
router.register('invoices', views.InvoiceViewSet)
|
|
10
11
|
router.register('serviceproviders', views.ServiceProviderViewSet)
|
|
11
12
|
router.register('contractassignment', views.ContractAssignmentViewSet)
|
|
@@ -7,6 +7,7 @@ from .serializers import (
|
|
|
7
7
|
AccountingDimensionSerializer,
|
|
8
8
|
ContractAssignmentSerializer,
|
|
9
9
|
ContractSerializer,
|
|
10
|
+
ContractTypeSerializer,
|
|
10
11
|
InvoiceLineSerializer,
|
|
11
12
|
InvoiceSerializer,
|
|
12
13
|
ServiceProviderSerializer,
|
|
@@ -51,3 +52,8 @@ class InvoiceLineViewSet(NetBoxModelViewSet):
|
|
|
51
52
|
class AccountingDimensionViewSet(NetBoxModelViewSet):
|
|
52
53
|
queryset = models.AccountingDimension.objects.prefetch_related('tags')
|
|
53
54
|
serializer_class = AccountingDimensionSerializer
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class ContractTypeViewSet(NetBoxModelViewSet):
|
|
58
|
+
queryset = models.ContractType.objects.prefetch_related('tags')
|
|
59
|
+
serializer_class = ContractTypeSerializer
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from django.db.models import Q
|
|
2
|
+
|
|
3
|
+
SERVICE_PROVIDER_MODELS = Q(
|
|
4
|
+
Q(app_label='circuits', model__in=('provider',))
|
|
5
|
+
| Q(app_label='netbox_contract', model__in=('serviceprovider',))
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
ASSIGNEMENT_MODELS = Q(
|
|
9
|
+
Q(app_label='circuits', model__in=('circuit',))
|
|
10
|
+
| Q(app_label='dcim', model__in=('site',))
|
|
11
|
+
| Q(app_label='dcim', model__in=('device',))
|
|
12
|
+
| Q(app_label='virtualization', model__in=('virtualmachine',))
|
|
13
|
+
)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import django_filters
|
|
2
2
|
from django.db.models import Q
|
|
3
3
|
from netbox.filtersets import NetBoxModelFilterSet
|
|
4
|
-
from tenancy.filtersets import TenancyFilterSet
|
|
4
|
+
from tenancy.filtersets import ContactModelFilterSet, TenancyFilterSet
|
|
5
5
|
|
|
6
6
|
from .models import (
|
|
7
7
|
AccountingDimension,
|
|
8
8
|
AccountingDimensionStatusChoices,
|
|
9
9
|
Contract,
|
|
10
10
|
ContractAssignment,
|
|
11
|
+
ContractType,
|
|
11
12
|
CurrencyChoices,
|
|
12
13
|
InternalEntityChoices,
|
|
13
14
|
Invoice,
|
|
@@ -17,7 +18,7 @@ from .models import (
|
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
class ContractFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
|
21
|
+
class ContractFilterSet(ContactModelFilterSet, NetBoxModelFilterSet, TenancyFilterSet):
|
|
21
22
|
status = django_filters.MultipleChoiceFilter(choices=StatusChoices, null_value=None)
|
|
22
23
|
internal_partie = django_filters.MultipleChoiceFilter(
|
|
23
24
|
choices=InternalEntityChoices, null_value=None
|
|
@@ -25,12 +26,16 @@ class ContractFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
|
|
25
26
|
currency = django_filters.MultipleChoiceFilter(
|
|
26
27
|
choices=CurrencyChoices, null_value=None
|
|
27
28
|
)
|
|
29
|
+
contract_type = django_filters.ModelMultipleChoiceFilter(
|
|
30
|
+
field_name='contract_type__name', to_field_name='name', queryset=ContractType.objects.all()
|
|
31
|
+
)
|
|
28
32
|
|
|
29
33
|
class Meta:
|
|
30
34
|
model = Contract
|
|
31
35
|
fields = (
|
|
32
36
|
'id',
|
|
33
37
|
'name',
|
|
38
|
+
'contract_type',
|
|
34
39
|
'external_reference',
|
|
35
40
|
'start_date',
|
|
36
41
|
'end_date',
|
|
@@ -71,7 +76,7 @@ class InvoiceFilterSet(NetBoxModelFilterSet):
|
|
|
71
76
|
)
|
|
72
77
|
|
|
73
78
|
|
|
74
|
-
class ServiceProviderFilterSet(NetBoxModelFilterSet):
|
|
79
|
+
class ServiceProviderFilterSet(ContactModelFilterSet, NetBoxModelFilterSet):
|
|
75
80
|
class Meta:
|
|
76
81
|
model = ServiceProvider
|
|
77
82
|
fields = ('id', 'name')
|
|
@@ -80,6 +85,15 @@ class ServiceProviderFilterSet(NetBoxModelFilterSet):
|
|
|
80
85
|
return queryset.filter(name__icontains=value)
|
|
81
86
|
|
|
82
87
|
|
|
88
|
+
class ContractTypeFilterSet(NetBoxModelFilterSet):
|
|
89
|
+
class Meta:
|
|
90
|
+
model = ContractType
|
|
91
|
+
fields = ('name', 'description', 'color')
|
|
92
|
+
|
|
93
|
+
def search(self, queryset, name, value):
|
|
94
|
+
return queryset.filter(name__icontains=value)
|
|
95
|
+
|
|
96
|
+
|
|
83
97
|
class ContractAssignmentFilterSet(NetBoxModelFilterSet):
|
|
84
98
|
class Meta:
|
|
85
99
|
model = ContractAssignment
|
|
@@ -9,9 +9,11 @@ from netbox.forms import (
|
|
|
9
9
|
NetBoxModelForm,
|
|
10
10
|
NetBoxModelImportForm,
|
|
11
11
|
)
|
|
12
|
+
from tenancy.forms import ContactModelFilterForm, TenancyFilterForm
|
|
12
13
|
from tenancy.models import Tenant
|
|
13
14
|
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES
|
|
14
15
|
from utilities.forms.fields import (
|
|
16
|
+
ColorField,
|
|
15
17
|
CommentField,
|
|
16
18
|
ContentTypeChoiceField,
|
|
17
19
|
CSVChoiceField,
|
|
@@ -25,12 +27,13 @@ from utilities.forms.fields import (
|
|
|
25
27
|
)
|
|
26
28
|
from utilities.forms.widgets import DatePicker, HTMXSelect
|
|
27
29
|
|
|
28
|
-
from .constants import SERVICE_PROVIDER_MODELS
|
|
30
|
+
from .constants import ASSIGNEMENT_MODELS, SERVICE_PROVIDER_MODELS
|
|
29
31
|
from .models import (
|
|
30
32
|
AccountingDimension,
|
|
31
33
|
AccountingDimensionStatusChoices,
|
|
32
34
|
Contract,
|
|
33
35
|
ContractAssignment,
|
|
36
|
+
ContractType,
|
|
34
37
|
CurrencyChoices,
|
|
35
38
|
InternalEntityChoices,
|
|
36
39
|
Invoice,
|
|
@@ -62,6 +65,9 @@ class ContractForm(NetBoxModelForm):
|
|
|
62
65
|
selector=True,
|
|
63
66
|
label=_('Parent'),
|
|
64
67
|
)
|
|
68
|
+
contract_type = DynamicModelChoiceField(
|
|
69
|
+
queryset=ContractType.objects.all(), required=False, selector=True, label=_('Contract type')
|
|
70
|
+
)
|
|
65
71
|
|
|
66
72
|
def __init__(self, *args, **kwargs):
|
|
67
73
|
initial = kwargs.get('initial', None)
|
|
@@ -100,6 +106,7 @@ class ContractForm(NetBoxModelForm):
|
|
|
100
106
|
model = Contract
|
|
101
107
|
fields = (
|
|
102
108
|
'name',
|
|
109
|
+
'contract_type',
|
|
103
110
|
'external_partie_object_type',
|
|
104
111
|
'external_partie_object',
|
|
105
112
|
'external_reference',
|
|
@@ -134,10 +141,15 @@ class ContractForm(NetBoxModelForm):
|
|
|
134
141
|
raise ValidationError('you should set monthly OR yearly recuring costs not both')
|
|
135
142
|
|
|
136
143
|
|
|
137
|
-
class ContractFilterForm(NetBoxModelFilterSetForm):
|
|
144
|
+
class ContractFilterForm(ContactModelFilterForm, TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
138
145
|
model = Contract
|
|
139
146
|
|
|
140
|
-
|
|
147
|
+
contract_type = DynamicModelChoiceField(
|
|
148
|
+
queryset=ContractType.objects.all(),
|
|
149
|
+
required=False,
|
|
150
|
+
selector=True,
|
|
151
|
+
label=_('Contract type'),
|
|
152
|
+
)
|
|
141
153
|
external_reference = forms.CharField(required=False, label=_('External reference'))
|
|
142
154
|
internal_partie = forms.ChoiceField(choices=InternalEntityChoices, required=False, label=_('Internal partie'))
|
|
143
155
|
status = forms.ChoiceField(choices=StatusChoices, required=False, label=_('Status'))
|
|
@@ -175,11 +187,19 @@ class ContractCSVForm(NetBoxModelImportForm):
|
|
|
175
187
|
required=False,
|
|
176
188
|
label=_('Parent'),
|
|
177
189
|
)
|
|
190
|
+
contract_type = CSVModelChoiceField(
|
|
191
|
+
queryset=ContractType.objects.all(),
|
|
192
|
+
to_field_name='name',
|
|
193
|
+
help_text='Contract type name',
|
|
194
|
+
required=False,
|
|
195
|
+
label=_('Contract type'),
|
|
196
|
+
)
|
|
178
197
|
|
|
179
198
|
class Meta:
|
|
180
199
|
model = Contract
|
|
181
200
|
fields = [
|
|
182
201
|
'name',
|
|
202
|
+
'contract_type',
|
|
183
203
|
'external_partie_object_type',
|
|
184
204
|
'external_partie_object_id',
|
|
185
205
|
'external_reference',
|
|
@@ -210,6 +230,12 @@ class ContractCSVForm(NetBoxModelImportForm):
|
|
|
210
230
|
|
|
211
231
|
class ContractBulkEditForm(NetBoxModelBulkEditForm):
|
|
212
232
|
name = forms.CharField(max_length=100, required=False, label=_('Name'))
|
|
233
|
+
contract_type = DynamicModelChoiceField(
|
|
234
|
+
queryset=ContractType.objects.all(),
|
|
235
|
+
required=False,
|
|
236
|
+
selector=True,
|
|
237
|
+
label=_('Contract Type')
|
|
238
|
+
)
|
|
213
239
|
external_reference = forms.CharField(max_length=100, required=False, label=_('External reference'))
|
|
214
240
|
internal_partie = forms.ChoiceField(choices=InternalEntityChoices, required=False, label=_('Internal partie'))
|
|
215
241
|
tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(), required=False, selector=True, label=_('Tenant'))
|
|
@@ -225,6 +251,44 @@ class ContractBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
225
251
|
model = Contract
|
|
226
252
|
|
|
227
253
|
|
|
254
|
+
# ContractType
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class ContractTypeForm(NetBoxModelForm):
|
|
258
|
+
color = ColorField(label=_('Color'))
|
|
259
|
+
|
|
260
|
+
class Meta:
|
|
261
|
+
model = ContractType
|
|
262
|
+
fields = (
|
|
263
|
+
'name',
|
|
264
|
+
'description',
|
|
265
|
+
'color',
|
|
266
|
+
'tags',
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class ContractTypeCSVForm(NetBoxModelImportForm):
|
|
271
|
+
name = forms.CharField(max_length=100, label=_('Name'))
|
|
272
|
+
description = CommentField(label=_('Description'))
|
|
273
|
+
color = ColorField(label=_('Color'))
|
|
274
|
+
|
|
275
|
+
class Meta:
|
|
276
|
+
model = ContractType
|
|
277
|
+
fields = ['name', 'description', 'color']
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
class ContractTypeBulkEditForm(NetBoxModelBulkEditForm):
|
|
281
|
+
description = CommentField(label=_('Description'))
|
|
282
|
+
nullable_fields = ('comments',)
|
|
283
|
+
color = ColorField(label=_('Color'), required=False,)
|
|
284
|
+
model = ContractType
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
class ContractTypeFilterForm(NetBoxModelFilterSetForm):
|
|
288
|
+
model = ContractType
|
|
289
|
+
name = forms.CharField(required=False, label=_('Name'))
|
|
290
|
+
description = CommentField(label=_('Description'))
|
|
291
|
+
|
|
228
292
|
# Invoice
|
|
229
293
|
|
|
230
294
|
|
|
@@ -353,7 +417,7 @@ class InvoiceFilterForm(NetBoxModelFilterSetForm):
|
|
|
353
417
|
|
|
354
418
|
|
|
355
419
|
class InvoiceCSVForm(NetBoxModelImportForm):
|
|
356
|
-
contracts =
|
|
420
|
+
contracts = CSVModelMultipleChoiceField(
|
|
357
421
|
queryset=Contract.objects.all(),
|
|
358
422
|
to_field_name='name',
|
|
359
423
|
help_text='Related Contracts',
|
|
@@ -378,7 +442,7 @@ class InvoiceCSVForm(NetBoxModelImportForm):
|
|
|
378
442
|
|
|
379
443
|
|
|
380
444
|
class InvoiceBulkEditForm(NetBoxModelBulkEditForm):
|
|
381
|
-
number = forms.CharField(max_length=100, required=
|
|
445
|
+
number = forms.CharField(max_length=100, required=False, label=_('Number'))
|
|
382
446
|
template = forms.BooleanField(
|
|
383
447
|
required=False,
|
|
384
448
|
label=_('Template'),
|
|
@@ -437,7 +501,7 @@ class ServiceProviderForm(NetBoxModelForm):
|
|
|
437
501
|
fields = ('name', 'slug', 'portal_url', 'comments', 'tags')
|
|
438
502
|
|
|
439
503
|
|
|
440
|
-
class ServiceProviderFilterForm(NetBoxModelFilterSetForm):
|
|
504
|
+
class ServiceProviderFilterForm(ContactModelFilterForm, NetBoxModelFilterSetForm):
|
|
441
505
|
model = ServiceProvider
|
|
442
506
|
name = forms.CharField(required=False, label=_('Name'))
|
|
443
507
|
tag = TagFilterField(model)
|
|
@@ -453,7 +517,7 @@ class ServiceProviderCSVForm(NetBoxModelImportForm):
|
|
|
453
517
|
|
|
454
518
|
|
|
455
519
|
class ServiceProviderBulkEditForm(NetBoxModelBulkEditForm):
|
|
456
|
-
name = forms.CharField(max_length=100, required=
|
|
520
|
+
name = forms.CharField(max_length=100, required=False, label=_('Name'))
|
|
457
521
|
comments = CommentField(label=_('Comments'))
|
|
458
522
|
nullable_fields = ('comments',)
|
|
459
523
|
model = ServiceProvider
|
|
@@ -463,21 +527,32 @@ class ServiceProviderBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
463
527
|
|
|
464
528
|
|
|
465
529
|
class ContractAssignmentForm(NetBoxModelForm):
|
|
466
|
-
|
|
530
|
+
|
|
531
|
+
content_type = ContentTypeChoiceField(
|
|
532
|
+
queryset=ContentType.objects.all(),
|
|
533
|
+
limit_choices_to=ASSIGNEMENT_MODELS,
|
|
534
|
+
label=_('object type'),
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
contract = DynamicModelChoiceField(
|
|
538
|
+
queryset=Contract.objects.all(),
|
|
539
|
+
selector=True,
|
|
540
|
+
label=_('Contract'))
|
|
467
541
|
|
|
468
542
|
class Meta:
|
|
469
543
|
model = ContractAssignment
|
|
470
544
|
fields = ['content_type', 'object_id', 'contract', 'tags']
|
|
471
|
-
widgets = {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
545
|
+
# widgets = {
|
|
546
|
+
# 'content_type': forms.HiddenInput(),
|
|
547
|
+
# 'object_id': forms.HiddenInput(),
|
|
548
|
+
# }
|
|
475
549
|
|
|
476
550
|
|
|
477
551
|
class ContractAssignmentFilterForm(NetBoxModelFilterSetForm):
|
|
478
552
|
model = ContractAssignment
|
|
479
553
|
contract = DynamicModelChoiceField(
|
|
480
554
|
queryset=Contract.objects.all(),
|
|
555
|
+
required=False,
|
|
481
556
|
selector=True,
|
|
482
557
|
label=_('Contract'),
|
|
483
558
|
)
|
|
@@ -486,6 +561,7 @@ class ContractAssignmentFilterForm(NetBoxModelFilterSetForm):
|
|
|
486
561
|
class ContractAssignmentImportForm(NetBoxModelImportForm):
|
|
487
562
|
content_type = CSVContentTypeField(
|
|
488
563
|
queryset=ContentType.objects.all(),
|
|
564
|
+
limit_choices_to=ASSIGNEMENT_MODELS,
|
|
489
565
|
help_text='Content Type in the form <app>.<model>',
|
|
490
566
|
label=_('Content type'),
|
|
491
567
|
)
|
|
@@ -500,6 +576,16 @@ class ContractAssignmentImportForm(NetBoxModelImportForm):
|
|
|
500
576
|
fields = ['content_type', 'object_id', 'contract', 'tags']
|
|
501
577
|
|
|
502
578
|
|
|
579
|
+
class ContractAssignmentBulkEditForm(NetBoxModelBulkEditForm):
|
|
580
|
+
contract = DynamicModelChoiceField(
|
|
581
|
+
queryset=Contract.objects.all(),
|
|
582
|
+
required=False,
|
|
583
|
+
selector=True,
|
|
584
|
+
label=_('Contract'),
|
|
585
|
+
)
|
|
586
|
+
model = ContractAssignment
|
|
587
|
+
|
|
588
|
+
|
|
503
589
|
# InvoiceLine
|
|
504
590
|
|
|
505
591
|
|
|
@@ -578,6 +664,7 @@ class InvoiceLineImportForm(NetBoxModelImportForm):
|
|
|
578
664
|
accounting_dimensions = CSVModelMultipleChoiceField(
|
|
579
665
|
queryset=AccountingDimension.objects.all(),
|
|
580
666
|
to_field_name='id',
|
|
667
|
+
required=False,
|
|
581
668
|
help_text='accounting dimension id',
|
|
582
669
|
label=_('Accounting dimensions'),
|
|
583
670
|
)
|
|
@@ -602,6 +689,8 @@ class InvoiceLineBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
602
689
|
selector=True,
|
|
603
690
|
label=_('Accounting dimensions'),
|
|
604
691
|
)
|
|
692
|
+
comments = CommentField(label=_('Comments'))
|
|
693
|
+
nullable_fields = ('comments',)
|
|
605
694
|
model = InvoiceLine
|
|
606
695
|
|
|
607
696
|
|
|
@@ -649,4 +738,6 @@ class AccountingDimensionImportForm(NetBoxModelImportForm):
|
|
|
649
738
|
class AccountingDimensionBulkEditForm(NetBoxModelBulkEditForm):
|
|
650
739
|
name = forms.CharField(max_length=20, required=False, label=_('Name'))
|
|
651
740
|
value = forms.CharField(max_length=20, required=False, label=_('Value'))
|
|
741
|
+
comments = CommentField(label=_('Comments'))
|
|
742
|
+
nullable_fields = ('comments',)
|
|
652
743
|
model = AccountingDimension
|
|
Binary file
|