mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Company reports (#9817)
* Support report generation against company * Add "print report" to Company table * Add printing button to Company detail page * Bump API version
This commit is contained in:
		| @@ -1,11 +1,14 @@ | ||||
| """InvenTree API version information.""" | ||||
|  | ||||
| # InvenTree API version | ||||
| INVENTREE_API_VERSION = 355 | ||||
| INVENTREE_API_VERSION = 356 | ||||
|  | ||||
| """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" | ||||
|  | ||||
| INVENTREE_API_TEXT = """ | ||||
| v356 -> 2025-06-20 : https://github.com/inventree/InvenTree/pull/9817 | ||||
|     - Enable generation of reports against the Company model type | ||||
|  | ||||
| v355 -> 2025-06-20 : https://github.com/inventree/InvenTree/pull/9811 | ||||
|     - Removes legacy "PartScheduling" API endpoints | ||||
|  | ||||
|   | ||||
| @@ -21,14 +21,12 @@ from taggit.managers import TaggableManager | ||||
|  | ||||
| import common.currency | ||||
| import common.models | ||||
| import common.settings | ||||
| import InvenTree.conversion | ||||
| import InvenTree.fields | ||||
| import InvenTree.helpers | ||||
| import InvenTree.models | ||||
| import InvenTree.ready | ||||
| import InvenTree.tasks | ||||
| import InvenTree.validators | ||||
| import report.mixins | ||||
| from common.currency import currency_code_default | ||||
| from InvenTree.fields import InvenTreeURLField, RoundingDecimalField | ||||
| from order.status_codes import PurchaseOrderStatusGroups | ||||
| @@ -56,9 +54,21 @@ def rename_company_image(instance, filename): | ||||
|     return os.path.join(base, fn) | ||||
|  | ||||
|  | ||||
| class CompanyReportContext(report.mixins.BaseReportContext): | ||||
|     """Report context for the Company model. | ||||
|  | ||||
|     Attributes: | ||||
|         name: The name of the Company | ||||
|         primary_address: The primary address associated with the Company | ||||
|     """ | ||||
|  | ||||
|     name: str | ||||
|  | ||||
|  | ||||
| class Company( | ||||
|     InvenTree.models.InvenTreeAttachmentMixin, | ||||
|     InvenTree.models.InvenTreeNotesMixin, | ||||
|     report.mixins.InvenTreeReportMixin, | ||||
|     InvenTree.models.InvenTreeMetadataModel, | ||||
| ): | ||||
|     """A Company object represents an external company. | ||||
| @@ -102,6 +112,10 @@ class Company( | ||||
|         """Return the API URL associated with the Company model.""" | ||||
|         return reverse('api-company-list') | ||||
|  | ||||
|     def report_context(self) -> CompanyReportContext: | ||||
|         """Generate a dict of context data to provide to the reporting framework.""" | ||||
|         return {'name': self.name} | ||||
|  | ||||
|     name = models.CharField( | ||||
|         max_length=100, | ||||
|         blank=False, | ||||
|   | ||||
| @@ -368,7 +368,7 @@ class PartManager(TreeManager): | ||||
|  | ||||
|  | ||||
| class PartReportContext(report.mixins.BaseReportContext): | ||||
|     """Context for the part model. | ||||
|     """Report context for the Part model. | ||||
|  | ||||
|     Attributes: | ||||
|         bom_items: Query set of all BomItem objects associated with the Part | ||||
|   | ||||
		Reference in New Issue
	
	Block a user