Models¶
nautobot_contract_models.models.contract.Contract
¶
Bases: PrimaryModel
A vendor agreement, with start/end dates, recurring + one-time costs, and a status.
Attaches to one or more concrete Nautobot objects (Devices, Circuits,
VirtualMachines, etc.) via :class:ContractAssignment — see that model's
docstring for why we use a generic FK rather than a per-target M2M.
Source code in src/nautobot_contract_models/models/contract.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
nautobot_contract_models.models.provider.ServiceProvider
¶
Bases: PrimaryModel
A vendor or counterparty that provides services under one or more Contracts.
Use Nautobot's Contact framework (associated_contacts) to track named
individuals (account manager, support rep, billing contact). The fields
here are vendor-level — the portal you log into, the main support line —
not contact-of-contact metadata.
Source code in src/nautobot_contract_models/models/provider.py
Meta
¶
nautobot_contract_models.models.invoice.Invoice
¶
Bases: PrimaryModel
One invoice / billing line belonging to a Contract.
Granularity: one row = one billing period. v1 doesn't model line-item breakdowns within an invoice — if an operator needs that, they add custom fields or build their own model.
Source code in src/nautobot_contract_models/models/invoice.py
is_paid
property
¶
True once a paid_date has been recorded.
Meta
¶
Model metadata.
Source code in src/nautobot_contract_models/models/invoice.py
nautobot_contract_models.models.assignment.ContractAssignment
¶
Bases: PrimaryModel
Link a :class:Contract to any Nautobot object that has a UUID PK.
Why generic FK rather than a typed M2M? We want one model to handle Contract-to-Device, Contract-to-Circuit, Contract-to-VirtualMachine, Contract-to-PowerFeed, etc. without a per-target-type table. Django's ContentType + GenericForeignKey gives us that. Operators can attach a Contract to anything in the Nautobot ORM — we don't have to enumerate the supported targets up front.
Subclasses :class:PrimaryModel (matching Nautobot's own
:class:ContactAssociation, which is the canonical GFK-link model). The
full PrimaryModel surface — ChangeLog, custom fields, tags, Relationships,
dynamic groups — applies. ChangeLog in particular matters: operators want
to see "who linked this Contract to that Device, and when".
Phase-2's earlier choice of BaseModel was wrong for this reason:
NautobotModelForm expects RelationshipModelMixin on the model
(which BaseModel doesn't include), so the create form 500s on
instance.get_relationships(). Promoting to PrimaryModel fixes the
immediate bug AND aligns with how Nautobot itself models GFK links.
Source code in src/nautobot_contract_models/models/assignment.py
nautobot_contract_models.models.attachment.ContractAttachment
¶
Bases: _AttachmentBase
A single file uploaded against a :class:Contract.
Common contents: the signed contract PDF itself, vendor SOWs / proposals, renewal-letter scans, addenda. Operators usually upload one or two and reference them rarely — the typical access pattern is "I need to see the actual signed agreement".
Files land at contract_attachments/YYYY/MM/<filename>. Same volume,
same backup discipline as :class:InvoiceAttachment.
Source code in src/nautobot_contract_models/models/attachment.py
Meta
¶
nautobot_contract_models.models.attachment.InvoiceAttachment
¶
Bases: _AttachmentBase
A single file uploaded against an :class:Invoice.
The motivating use case: vendors send invoices as PDFs. Operators want to attach the actual PDF to the database row so future-them (or auditors) can see what the original looked like, not just the typed-in numbers.
Files land at invoice_attachments/YYYY/MM/<filename> under Nautobot's
MEDIA_ROOT and serve at /media/invoice_attachments/.... The
nautobot-media Docker volume persists them across restarts; production
deployments need a separate backup strategy for that volume since DB
dumps don't include media files.
Source code in src/nautobot_contract_models/models/attachment.py
Meta
¶
nautobot_contract_models.models.snapshot.CostSnapshot
¶
Bases: BaseModel
One per-currency aggregate of fleet contract costs on one date.
Source code in src/nautobot_contract_models/models/snapshot.py
Meta
¶
Model metadata.