2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-17 18:26:32 +00:00

Extend ReportMixin class to support labels (#4678)

* Extend ReportMixin context to shim label templates also

* Update docs
This commit is contained in:
Oliver
2023-04-22 23:46:43 +10:00
committed by GitHub
parent 50cbaff76d
commit 8df207d8e1
3 changed files with 29 additions and 0 deletions

View File

@@ -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):