2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 04:00:57 +00:00

Report Plugins (#4643)

* Add plugin mixin class for extending reports

* Expose report context to the plugin system

* Add an example mixin for adding context data to a report

* Add the 'request' object to the plugin code
This commit is contained in:
Oliver
2023-04-20 14:21:22 +10:00
committed by GitHub
parent a020548c8e
commit 68d1682000
5 changed files with 83 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import part.models
import stock.models
from InvenTree.helpers import validateFilterString
from InvenTree.models import MetadataMixin
from plugin.registry import registry
try:
from django_weasyprint import WeasyTemplateResponseMixin
@ -212,6 +213,12 @@ class ReportTemplateBase(MetadataMixin, ReportBase):
context['request'] = request
context['user'] = request.user
# Pass the context through to any active reporting plugins
plugins = registry.with_mixin('report')
for plugin in plugins:
plugin.add_report_context(self, request, context)
return context
def generate_filename(self, request, **kwargs):