From cc40af6199173cf6702fec66b0726c2a52a238a7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 21 Jun 2025 17:27:39 +1000 Subject: [PATCH] Fix missing context items (#9819) * Fix missing context items * Fix typo in docstring --- src/backend/InvenTree/InvenTree/models.py | 2 +- src/backend/InvenTree/company/models.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/models.py b/src/backend/InvenTree/InvenTree/models.py index 0afcf47cff..de4b806126 100644 --- a/src/backend/InvenTree/InvenTree/models.py +++ b/src/backend/InvenTree/InvenTree/models.py @@ -948,7 +948,7 @@ class InvenTreeBarcodeMixin(models.Model): This is used to generate a efficient QR code for the model type. It is expected to match this pattern: [0-9A-Z $%*+-.\/:]{2} - Note: Due to the shape constrains (45**2=2025 different allowed codes) + Note: Due to the shape constraints (45**2=2025 different allowed codes) this needs to be explicitly implemented in the model class to avoid collisions. """ raise NotImplementedError( diff --git a/src/backend/InvenTree/company/models.py b/src/backend/InvenTree/company/models.py index 333eeb2c36..e10e4aff8d 100644 --- a/src/backend/InvenTree/company/models.py +++ b/src/backend/InvenTree/company/models.py @@ -58,11 +58,22 @@ class CompanyReportContext(report.mixins.BaseReportContext): """Report context for the Company model. Attributes: + company: The Company object associated with this context name: The name of the Company - primary_address: The primary address associated with the Company + description: A description of the Company + website: The website URL for the Company + phone: The contact phone number for the Company + email: The contact email address for the Company + address: The primary address associated with the Company """ + company: 'Company' name: str + description: str + website: str + phone: str + email: str + address: str class Company( @@ -114,7 +125,15 @@ class Company( def report_context(self) -> CompanyReportContext: """Generate a dict of context data to provide to the reporting framework.""" - return {'name': self.name} + return { + 'company': self, + 'name': self.name, + 'description': self.description, + 'website': self.website, + 'phone': self.phone, + 'email': self.email, + 'address': str(self.address) if self.address else '', + } name = models.CharField( max_length=100,