Contract plugin
NetBox plugin to manage contracts.
- Free software: MIT
- Documentation: https://mlebreuil.github.io/netbox-contract/
Features
The plugin adds contracts and invoices model to NetBox.
It allows to link contract with objects.
Each contract is described by contract lines (one-time, recurring or usage-based, through units).
Invoices are linked with contracts; their amount is proposed and their invoice lines are generated from the contract lines.
Accounting dimensions can be linked with contract lines and invoice lines.
Compatibility
| NetBox Version | Plugin Version |
|---|---|
| 4.1 | 2.2 |
| 4.2 | 2.3 |
| 4.3 | 2.4 |
| 4.4 | 2.4 |
| 4.5 | 2.4 |
| 4.6 | 2.4, 2.5 |
| 4.7 | 2.6 |
Version 2.6 requires NetBox 4.7 or later. NetBox 4.6 installations stay on plugin 2.5.
Installing
Activate venv
To ensure our plugin is accessible to the NetBox installation, we first need to activate the Python virtual environment that was created when we installed NetBox. To do this, determine the virtual environment's path (this will be /opt/netbox/venv/ if you use the documentation's defaults) and activate it:
$ source /opt/netbox/venv/bin/activate
Install the package
$ python3 -m pip install netbox-contract
Configure NetBox
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:
# configuration.py
PLUGINS = [
'netbox_contract',
]
Customize the plugin
The following configuration items can be set:
# configuration.py
PLUGINS_CONFIG = {
'netbox_contract': {
'top_level_menu': True,
'mandatory_contract_fields': [],
'hidden_contract_fields': [],
'mandatory_invoice_fields': [],
'hidden_invoice_fields': [],
'mandatory_dimensions': [],
'supported_models': [
'circuits.circuit',
'circuits.virtualcircuit',
'dcim.site',
'dcim.device',
'dcim.rack',
'virtualization.virtualmachine',
'virtualization.cluster',
'ipam.ipaddress',
'ipam.prefix',
],
'contract_assignments_display': 'both', # options: 'tab', 'inline', 'both'
'show_deprecated_fields': False,
}
}
- top_level_menu : If "Contracts" appears under the "Plugins" menu item or on its own
- supported_models: The NetBox models a contract can be assigned to. Each model must be exposed in NetBox's REST API, because the assignment form searches its objects through it. A contract can be assigned to a given object only once.
- contract_assignments_display:
'tab'- only the Contracts view tab is visible on the related object page.'inline'- only the inline contract assignments table is shown in object detail; the Contracts tab is hidden.'both'- both tab and inline table are shown (default behavior).
- default_accounting_dimensions: The accounting dimensions which will appear in the field' background when empty. Note that accounting dimensions are now managed as individual objects. The use of this field is deprecated.
- mandatory_contract_fields, mandatory_invoice_fields: Fields which are not required by default and can be set as such. The list of fields is at the bottom of the contract import form.
- hidden_contract_fields, hidden_invoice_fields: List of fields to be hidden. Fields should not be required to be hidden. A deprecated field that is not shown is ignored, with a warning in the log. The legacy name
external_party_object_typeis an alias ofexternal_party_object. - show_deprecated_fields: show the deprecated contract cost fields (monthly, yearly and non-recurring costs, replaced by contract lines) in the contract form, detail page and tables, and allow creating new invoice templates. Default:
False.
Customize the plugin fields choices
Internal party reference the legal entity of your organization that is a party to the contract.
The first currency will also be the default currency for contracts.
# configuration.py
FIELD_CHOICES = {
'netbox_contract.Contract.internal_party': (
('default', 'Default entity', 'green'),
('entity1', 'Entity 1', 'green'),
('entity2', 'Entity 2', 'yellow'),
),
'netbox_contract.Contract.currency': (
('usd', 'USD'), # 1st position is the default currency
('eur', 'EUR'),
('chf', 'CHF'),
('pln', 'PLN'),
),
'netbox_contract.Contract.status': (
('active', 'Active', 'green'),
('canceled', 'Canceled', 'red'),
)
'netbox_contract.Invoice.status': (
('draft', 'Draft', 'yellow'),
('posted', 'Posted', 'green'),
('canceled', 'Canceled', 'red'),
)
}
Status and billing method options show a description under their name. The built-in options come with one. An option you add or
replace through FIELD_CHOICES can give its own with a dictionary entry; an option without a description is shown without one. Replacing all the options of a set, as in the example above, drops the built-in descriptions unless you give them again:
FIELD_CHOICES = {
'netbox_contract.Invoice.status+': [
{'value': 'on_hold', 'label': 'On hold', 'color': 'orange', 'description': 'Waiting for the customer approval'},
],
}
Run database migrations
(venv) $ cd /opt/netbox/netbox/
(venv) $ python3 manage.py migrate
Upgrading to version 2.5
The migration to version 2.5 converts the monthly, yearly and non-recurring costs and the invoice templates of existing contracts into contract lines, and prints a report of the judgement calls it made (for example an invoice template whose total differs from the recurring cost). Invoices, invoice lines, invoice templates and the deprecated fields are not changed. The conversion can be run again at any time; contracts that already have contract lines are skipped:
(venv) $ python3 manage.py convert_contract_lines
Upgrading to version 2.6: orphan assignments
Before version 2.6, deleting a device, site or other object left its contract assignments behind. From 2.6 the assignments are deleted with their object. The ones already left behind are not touched by the upgrade. List them, then delete them once you have looked at the list:
(venv) $ python3 manage.py cleanup_orphan_assignments # list only, nothing is changed
(venv) $ python3 manage.py cleanup_orphan_assignments --apply # delete the listed assignments
The report gives the number per object type and, for each assignment, its contract, the object type and the former identifier. Assignments whose object type is no longer installed are listed separately and are never deleted. Running the command again lists nothing once it is clean.
The custom script "Report currency mismatches" (in scripts/netbox-contract.py) lists existing records whose currency does not match their contract or invoice, without changing them.
Metadata
Release files for netbox-contract 2.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netbox_contract-2.6.0.tar.gz | 934.3 kB | With provenance | Details for netbox_contract-2.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netbox_contract-2.6.0-py3-none-any.whl | Python 3 | none | any | Details for netbox_contract-2.6.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / netbox_contract-2.6.0.tar.gz
| Download URL | netbox_contract-2.6.0.tar.gz |
|---|---|
| Size | 934.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecf9b087025a0312ed7c35df37b5922dd94dcd17600c8b1f624c89ada1e407b8
|
|
BLAKE2b-256 checksum How to use checksums |
d397c72d63759c96235ad3a8a402dcb33e52ab0e5cead620616a6626ae6f321d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / netbox_contract-2.6.0-py3-none-any.whl
| Download URL | netbox_contract-2.6.0-py3-none-any.whl |
|---|---|
| Size | 145.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20f34accddf50b0df1bbdd918c6b1bc128d830afcc141a45634e9ad6a9adcf2e
|
|
BLAKE2b-256 checksum How to use checksums |
14ddc72df9d89c4a1dcb6eef75e065d19b2239dfb80cfcc819c1d78323354c59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for netbox-contract 2.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for netbox_contract-2.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.