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:
@ -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):
|
||||
|
Reference in New Issue
Block a user