mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Extend ReportMixin class to support labels (#4678)
* Extend ReportMixin context to shim label templates also * Update docs
This commit is contained in:
		| @@ -18,6 +18,7 @@ import part.models | ||||
| import stock.models | ||||
| from InvenTree.helpers import normalize, validateFilterString | ||||
| from InvenTree.models import MetadataMixin | ||||
| from plugin.registry import registry | ||||
|  | ||||
| try: | ||||
|     from django_weasyprint import WeasyTemplateResponseMixin | ||||
| @@ -190,6 +191,13 @@ class LabelTemplate(MetadataMixin, models.Model): | ||||
|         context['width'] = self.width | ||||
|         context['height'] = self.height | ||||
|  | ||||
|         # Pass the context through to any registered plugins | ||||
|         plugins = registry.with_mixin('report') | ||||
|  | ||||
|         for plugin in plugins: | ||||
|             # Let each plugin add its own context data | ||||
|             plugin.add_label_context(self, self.object_to_print, request, context) | ||||
|  | ||||
|         return context | ||||
|  | ||||
|     def render_as_string(self, request, **kwargs): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user