Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report printing refactor #7074

Merged
merged 210 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
210 commits
Select commit Hold shift + click to select a range
8e42e08
Adds a new "generic" ReportTemplate model
SchrodingersGat Apr 20, 2024
d4761d0
expose API endpoints
SchrodingersGat Apr 20, 2024
afb0304
Update model / migrations / serializer
SchrodingersGat Apr 20, 2024
54d2dee
Add new mixin class to existing database models
SchrodingersGat Apr 20, 2024
3eea4fa
- Add detail view for report template
SchrodingersGat Apr 21, 2024
05a7d64
Filter report list by provided item IDs
SchrodingersGat Apr 21, 2024
71e7e5f
Create data migration for converting *old* report templates
SchrodingersGat Apr 21, 2024
fd4c000
Ignore internal reports for data migration
SchrodingersGat Apr 21, 2024
168801f
Add report mixin to StockLocation model
SchrodingersGat Apr 21, 2024
38a4866
Provide model choices in admin interface
SchrodingersGat Apr 21, 2024
7df6aae
Offload context data generation to the model classes
SchrodingersGat Apr 21, 2024
08e31da
Remove old report template models
SchrodingersGat Apr 21, 2024
1c464c0
Refactor JS code in CUI
SchrodingersGat Apr 21, 2024
b631a88
Fix for API filtering
SchrodingersGat Apr 21, 2024
afa6d57
Add data migration to delete old models
SchrodingersGat Apr 21, 2024
2dd6e11
Remove dead URL
SchrodingersGat Apr 21, 2024
d9689e4
Updates
SchrodingersGat Apr 21, 2024
63d3844
Construct sample report templates on app start
SchrodingersGat Apr 21, 2024
cf73110
Bump API version
SchrodingersGat Apr 21, 2024
c745d02
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat Apr 21, 2024
6f0e391
Typo fix
SchrodingersGat Apr 21, 2024
7988e5c
Fix incorrect context calls
SchrodingersGat Apr 21, 2024
50e4305
Merge branch 'master' into pui-reports
SchrodingersGat Apr 22, 2024
446c5ea
Add new LabelTemplate model
SchrodingersGat Apr 22, 2024
3804f55
Expose to admin interface
SchrodingersGat Apr 22, 2024
bde6d1f
Add in extra context from existing label models
SchrodingersGat Apr 22, 2024
baa4666
Add migration to create LabelTemplate instances from existing labels
SchrodingersGat Apr 22, 2024
61937e0
Add API endpoints for listing and updating LabelTemplate objects
SchrodingersGat Apr 22, 2024
e967b80
Adjust 'upload_to' path
SchrodingersGat Apr 22, 2024
134e534
Refactor label printing
SchrodingersGat Apr 22, 2024
49a8372
Move default label templates
SchrodingersGat Apr 22, 2024
9852f2c
Update API endpoints
SchrodingersGat Apr 22, 2024
7858e1a
Merge branch 'master' into pui-reports
SchrodingersGat Apr 25, 2024
57f7bac
Update migrations
SchrodingersGat Apr 25, 2024
3676e7e
Handle LookupError in migration
SchrodingersGat Apr 25, 2024
aa6b66a
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat Apr 29, 2024
eba2ee0
Redirect the "label" API endpoint
SchrodingersGat Apr 29, 2024
d1aee5f
Add new model for handling result of template printing
SchrodingersGat Apr 29, 2024
02c2664
Refactor LabelPrinting mixin
SchrodingersGat Apr 29, 2024
8b3a998
Unlink "labels" app entirely
SchrodingersGat Apr 29, 2024
ec23fdb
Fix typo
SchrodingersGat Apr 29, 2024
89a67cd
Record 'plugin' used to generate a particular output
SchrodingersGat Apr 29, 2024
1fc4c94
Fix imports
SchrodingersGat Apr 29, 2024
432a7fc
Generate label print response
SchrodingersGat Apr 29, 2024
1877310
Refactoring label printing in CUI
SchrodingersGat Apr 29, 2024
a9e75c4
add "items" count to TemplateOutput model
SchrodingersGat Apr 29, 2024
f39d6d9
Fix for InvenTreeLabelSheetPlugin
SchrodingersGat Apr 29, 2024
608e109
Remove old "label" app
SchrodingersGat Apr 29, 2024
58c8a02
Make request object optional
SchrodingersGat Apr 29, 2024
97868ce
Fix filename generation
SchrodingersGat Apr 29, 2024
229fb5c
Add help text for "model_type"
SchrodingersGat Apr 29, 2024
bf6eea9
Simplify TemplateTable
SchrodingersGat Apr 29, 2024
35fe645
Tweak TemplateTable
SchrodingersGat Apr 29, 2024
2daa5a9
Get template editor to display template data again
SchrodingersGat Apr 29, 2024
17a915c
Stringify template name
SchrodingersGat Apr 29, 2024
2a12e54
Add hooks to reset plugin state
SchrodingersGat Apr 29, 2024
88b778b
fix context for StockLocation model
SchrodingersGat Apr 29, 2024
40ce04b
Tweak log messages
SchrodingersGat Apr 29, 2024
e565d36
Fix incorrect serializer
SchrodingersGat Apr 29, 2024
d842024
Cleanup TemplateTable
SchrodingersGat Apr 29, 2024
2bb5ed7
Fix broken import
SchrodingersGat Apr 29, 2024
a6950be
Filter by target model type
SchrodingersGat Apr 29, 2024
ebbed40
Merge branch 'master' into pui-reports
SchrodingersGat Apr 29, 2024
924ddf4
Remove manual file operations
SchrodingersGat Apr 30, 2024
52c7343
Update old migrations
SchrodingersGat Apr 30, 2024
89d61c7
Refactor asset / snippet uploading
SchrodingersGat Apr 30, 2024
326f390
Update comments
SchrodingersGat Apr 30, 2024
470a706
Retain original filename when editing templatese
SchrodingersGat Apr 30, 2024
b5a0b01
Cleanup
SchrodingersGat Apr 30, 2024
3cf3ae9
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat Apr 30, 2024
414ca23
Refactor model type filter to use new hook
SchrodingersGat Apr 30, 2024
cb50785
Add placeholder actions for printing labels and reports
SchrodingersGat Apr 30, 2024
0d60955
Improve hookiness
SchrodingersGat Apr 30, 2024
e22710d
Add new ReportOutput class
SchrodingersGat Apr 30, 2024
9d64bba
Report printing works from PUI now!
SchrodingersGat Apr 30, 2024
4c09541
More inspired filename pattern for generated reports
SchrodingersGat Apr 30, 2024
b7b3af9
Fix template preview window
SchrodingersGat Apr 30, 2024
a330b41
Remove outdated task
SchrodingersGat Apr 30, 2024
f910501
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat Apr 30, 2024
6b2e849
Update data migration to use raw SQL
SchrodingersGat May 1, 2024
e53d705
Add more API endpoint defs
SchrodingersGat May 1, 2024
aaff3cb
Adds placeholder API endpoint for label printing
SchrodingersGat May 1, 2024
5889135
Expose plugin field to the printing endpoint
SchrodingersGat May 1, 2024
bb37707
Adds plugin model type
SchrodingersGat May 1, 2024
937ec3e
Hook to print labels
SchrodingersGat May 1, 2024
27b79e3
Refactor action dropdown items
SchrodingersGat May 1, 2024
eff9b1a
Refactor report printing for CUI
SchrodingersGat May 2, 2024
a5e42c9
Refactor label print for CUI
SchrodingersGat May 2, 2024
c6b3629
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 2, 2024
97e1585
Fix migration
SchrodingersGat May 2, 2024
7f55689
Update ModelType dict
SchrodingersGat May 2, 2024
90c6b2b
Merge branch 'master' into pui-reports
SchrodingersGat May 3, 2024
26af44c
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 3, 2024
0bf9189
playwright test fix
SchrodingersGat May 3, 2024
8cede34
Unit test fixes
SchrodingersGat May 3, 2024
22c6381
Fix model ruleset associations
SchrodingersGat May 3, 2024
fb697dc
Fix for report.js
SchrodingersGat May 3, 2024
6c3a1b3
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 5, 2024
b56be87
Add support for "dynamic" fields in metadata.py
SchrodingersGat May 5, 2024
ecfb505
Add in custom fields based on plugin
SchrodingersGat May 5, 2024
a3bbe26
Refactoring
SchrodingersGat May 5, 2024
6e034a3
Reset plugin on form close
SchrodingersGat May 5, 2024
b0cbd1f
Set custom timeout values
SchrodingersGat May 5, 2024
8dda653
Update migration
SchrodingersGat May 5, 2024
a414612
Cleanup
SchrodingersGat May 5, 2024
f6a769e
Implement more printing actions
SchrodingersGat May 5, 2024
82b743f
Reduce timeout
SchrodingersGat May 6, 2024
6a6cf31
Unit test updates
SchrodingersGat May 6, 2024
9d270be
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 7, 2024
8af0c88
Merge branch 'master' into pui-reports
SchrodingersGat May 9, 2024
c481624
Fix part serializers
SchrodingersGat May 9, 2024
09c0d58
Label printing works in CUI again
SchrodingersGat May 9, 2024
f02c2b6
js linting
SchrodingersGat May 9, 2024
0e7333b
Update <ActionDropdown>
SchrodingersGat May 9, 2024
8921b60
Fix for label printing API endpoint
SchrodingersGat May 9, 2024
847dfa6
Fix filterselectdrawer
SchrodingersGat May 9, 2024
6129021
Improve button rendering
SchrodingersGat May 9, 2024
d137829
Allow printing from StockLocationTable
SchrodingersGat May 9, 2024
c8c360a
Add aria-labels to modal form fields
SchrodingersGat May 9, 2024
7a74f5e
Add test for printing stock item labels from table
SchrodingersGat May 9, 2024
6cba780
Add test for report printing
SchrodingersGat May 9, 2024
e854b86
Add unit testing for report template editing / preview
SchrodingersGat May 9, 2024
88f9d59
Message refactor
SchrodingersGat May 9, 2024
956e93c
Refactor InvenTreeReportMixin class
SchrodingersGat May 9, 2024
6ebedc7
Update playwright test
SchrodingersGat May 10, 2024
ca73867
Update 'verbose_name' for a number of models
SchrodingersGat May 10, 2024
d6c6715
Additional admin filtering
SchrodingersGat May 10, 2024
d3136da
Playwright test updates
SchrodingersGat May 10, 2024
7257464
Run checks against new python lib branch
SchrodingersGat May 10, 2024
2a2451b
remove old app reference
matmair May 10, 2024
bed64b9
fix testing ref
matmair May 10, 2024
891220d
fix app init
matmair May 10, 2024
bd938ce
remove old tests
matmair May 10, 2024
7032ab3
Revert custom target branch
SchrodingersGat May 11, 2024
fbe3be4
Expose label and report output objects to API
SchrodingersGat May 11, 2024
9349781
refactor
SchrodingersGat May 12, 2024
e71ca54
fix a few tests
matmair May 13, 2024
9c13dcc
factor plugin_ref out
matmair May 13, 2024
4b5d70a
fix options testing
matmair May 13, 2024
45d56e1
Merge branch 'master' into pui-reports
SchrodingersGat May 13, 2024
e8b803a
Update table field header
SchrodingersGat May 13, 2024
afc66d4
Merge branch 'pui-reports' of github.com:SchrodingersGat/InvenTree in…
SchrodingersGat May 13, 2024
70504fa
re-enable full options testing
matmair May 14, 2024
9b9035c
fix missing plugin matching
matmair May 14, 2024
5908149
disable call assert
matmair May 14, 2024
d2d62b4
Add custom related field for PluginConfig
SchrodingersGat May 14, 2024
aeae153
Add support for custom pk field in metadata
SchrodingersGat May 14, 2024
d7994b1
switch to labels for testing
matmair May 14, 2024
0807e85
re-align report testing code
matmair May 14, 2024
070724b
disable version check
matmair May 14, 2024
e38818e
Merge branch 'pr/SchrodingersGat/7074' into 7074-testing
matmair May 14, 2024
8581aea
fix url
matmair May 14, 2024
a5c6a20
Implement lazy loading
SchrodingersGat May 14, 2024
121863b
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 15, 2024
9d1fe1f
Allow blank plugin for printing
SchrodingersGat May 15, 2024
e9101fe
Add printing actions for StockItem
SchrodingersGat May 15, 2024
9b50705
Fix for metadata helper
SchrodingersGat May 15, 2024
a2287ef
Use key instead of pk in printing actions
SchrodingersGat May 15, 2024
15e4be4
Support non-standard pk values in RelatedModelField
SchrodingersGat May 15, 2024
f9e5128
pass context data to report serializers
matmair May 15, 2024
3dc7750
disable template / item discovery
matmair May 15, 2024
23dbf10
fix call
matmair May 15, 2024
1f2a3fb
Tweak unit test
SchrodingersGat May 15, 2024
ce25b64
Run python checks against specific branch
SchrodingersGat May 15, 2024
a5ad2d7
Add task for running docs server
SchrodingersGat May 15, 2024
f666234
Custom branch no longer needed
SchrodingersGat May 15, 2024
a62a790
Merge branch 'pr/SchrodingersGat/7074' into 7074-testing
matmair May 15, 2024
91d4985
Starting on documentation updates
SchrodingersGat May 15, 2024
a9bda1c
Merge pull request #3 from matmair/7074-testing
SchrodingersGat May 15, 2024
ba8c397
fix tests for reports
matmair May 15, 2024
764895f
fix label testing
matmair May 16, 2024
7e5d4c5
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair May 16, 2024
f84910a
Merge branch 'master' into pui-reports
SchrodingersGat May 16, 2024
07e601f
Update template context variables
SchrodingersGat May 16, 2024
7ce5188
Refactor report context documentation
SchrodingersGat May 16, 2024
e7b84ae
Documentation cleanup
SchrodingersGat May 16, 2024
9dc2122
Docs cleanup
SchrodingersGat May 16, 2024
42415e6
Include sample report files
SchrodingersGat May 16, 2024
3a15e34
Fix links
SchrodingersGat May 16, 2024
60ea32c
Link cleanup
SchrodingersGat May 16, 2024
7ad234f
Integrate plugin example code into docs
SchrodingersGat May 16, 2024
6ec2ee6
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 16, 2024
2dfce1f
Code cleanup
SchrodingersGat May 16, 2024
0489ac9
Fix type annotation
SchrodingersGat May 16, 2024
e63528b
Merge branch 'master' into pui-reports
SchrodingersGat May 17, 2024
9fb26c5
Revert deleted variable
SchrodingersGat May 17, 2024
836567e
remove templatetype
SchrodingersGat May 17, 2024
708b200
remove unused imports
SchrodingersGat May 17, 2024
0ceebea
extend context testing
matmair May 17, 2024
a3bf3d1
Merge branch 'pui-reports' of https://github.com/schrodingersgat/inve…
matmair May 17, 2024
d2616a8
test if plg can print
matmair May 17, 2024
c96f594
re-enable version check
matmair May 17, 2024
f3caa05
Merge branch 'pui-reports' of github.com:SchrodingersGat/InvenTree in…
SchrodingersGat May 19, 2024
51cf611
Merge branch 'master' into pui-reports
SchrodingersGat May 19, 2024
88d1803
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 20, 2024
b5b8224
Update unit tests
SchrodingersGat May 20, 2024
e938e37
Fix test
SchrodingersGat May 20, 2024
5d8cb2a
Adjust unit test
SchrodingersGat May 20, 2024
70e35f4
Add debug statement to test
SchrodingersGat May 20, 2024
99991a8
Fix unit test
SchrodingersGat May 20, 2024
421e973
Unit test update
SchrodingersGat May 20, 2024
31229e3
Unit test updates
SchrodingersGat May 20, 2024
f91f31f
Merge remote-tracking branch 'origin/master' into pui-reports
SchrodingersGat May 21, 2024
3b844f6
Test update
SchrodingersGat May 21, 2024
528c687
Patch fix for <PartColumn> component
SchrodingersGat May 21, 2024
79392a7
Fix ReportSerialierBase class
SchrodingersGat May 21, 2024
bc194b8
Fix unit test for sqlite
SchrodingersGat May 21, 2024
1da0b30
Fix kwargs for non-blocking label printing
SchrodingersGat May 21, 2024
aaeda32
Update playwright tests
SchrodingersGat May 21, 2024
07ca9a1
Tweak unit test
SchrodingersGat May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ src/backend/InvenTree/web/static
InvenTree/web/static

# Generated docs files
docs/schema.yml
docs/docs/api/*.yml
docs/docs/api/schema/*.yml
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion docs/docs/extend/plugins/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@ POST {
}
```

For an example of a very simple action plugin, refer to `/src/backend/InvenTree/plugin/samples/integratoni/simpleactionplugin.py`
### Sample Plugin

A sample action plugin is provided in the `InvenTree` source code, which can be used as a template for creating custom action plugins:

::: plugin.samples.integration.simpleactionplugin.SimpleActionPlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []
12 changes: 12 additions & 0 deletions docs/docs/extend/plugins/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ title: Schedule Mixin
## APICallMixin

The APICallMixin class provides basic functionality for integration with an external API.

### Sample Plugin

The following example demonstrates how to use the `APICallMixin` class to make a simple API call:

::: plugin.samples.integration.api_caller.SampleApiCallerPlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []
18 changes: 16 additions & 2 deletions docs/docs/extend/plugins/barcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Barcode Mixin
---

### Barcode Plugins
## Barcode Plugins

InvenTree supports decoding of arbitrary barcode data via a **Barcode Plugin** interface. Barcode data POSTed to the `/api/barcode/` endpoint will be supplied to all loaded barcode plugins, and the first plugin to successfully interpret the barcode data will return a response to the client.

Expand All @@ -24,7 +24,21 @@ POST {
}
```

### Example
### Builtin Plugin

The InvenTree server includes a builtin barcode plugin which can decode QR codes generated by the server. This plugin is enabled by default.

::: plugin.builtin.barcodes.inventree_barcode.InvenTreeInternalBarcodePlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []


### Example Plugin

Please find below a very simple example that is executed each time a barcode is scanned.

```python
Expand Down
19 changes: 18 additions & 1 deletion docs/docs/extend/plugins/currency.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,24 @@ title: Currency Exchange Mixin

The `CurrencyExchangeMixin` class enabled plugins to provide custom backends for updating currency exchange rate information.

Any implementing classes must provide the `update_exchange_rates` method. A simple example is shown below (with fake data).
Any implementing classes must provide the `update_exchange_rates` method.

### Builtin Plugin

The default builtin plugin for handling currency exchange rates is the `InvenTreeCurrencyExchangePlugin` class.

::: plugin.builtin.integration.currency_exchange.InvenTreeCurrencyExchange
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []


### Sample Plugin

A simple example is shown below (with fake data).

```python

Expand Down
56 changes: 17 additions & 39 deletions docs/docs/extend/plugins/event.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,34 @@ When a certain (server-side) event occurs, the background worker passes the even
{% include 'img.html' %}
{% endwith %}

### Example (all events)
### Sample Plugin - All events

Implementing classes must at least provide a `process_event` function:

```python
class EventPlugin(EventMixin, InvenTreePlugin):
"""
A simple example plugin which responds to events on the InvenTree server.
::: plugin.samples.event.event_sample.EventPluginSample
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

This example simply prints out the event information.
A more complex plugin could respond to specific events however it wanted.
"""

NAME = "EventPlugin"
SLUG = "event"
TITLE = "Triggered Events"

def process_event(self, event, *args, **kwargs):
print(f"Processing triggered event: '{event}'")
```

### Example (specific events)
### Sample Plugin - Specific Events

If you want to process just some specific events, you can also implement the `wants_process_event` function to decide if you want to process this event or not. This function will be executed synchronously, so be aware that it should contain simple logic.

Overall this function can reduce the workload on the background workers significantly since less events are queued to be processed.

```python
class EventPlugin(EventMixin, InvenTreePlugin):
"""
A simple example plugin which responds to 'salesordershipment.completed' event on the InvenTree server.

This example simply prints out the event information.
A more complex plugin can run enhanced logic on this event.
"""

NAME = "EventPlugin"
SLUG = "event"
TITLE = "Triggered Events"

def wants_process_event(self, event):
"""Here you can decide if this event should be send to `process_event` or not."""
return event == "salesordershipment.completed"
::: plugin.samples.event.filtered_event_sample.FilteredEventPluginSample
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

def process_event(self, event, *args, **kwargs):
"""Here you can run you'r specific logic."""
print(f"Sales order was completely shipped: '{args}' '{kwargs}'")
```

### Events
## Events

Events are passed through using a string identifier, e.g. `build.completed`

Expand Down
8 changes: 8 additions & 0 deletions docs/docs/extend/plugins/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ InvenTree supplies the `InvenTreeLabelPlugin` out of the box, which generates a

The default plugin also features a *DEBUG* mode which generates a raw HTML output, rather than PDF. This can be handy for tracking down any template rendering errors in your labels.

::: plugin.builtin.labels.inventree_label.InvenTreeLabelPlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

### Available Data

The *label* data are supplied to the plugin in both `PDF` and `PNG` formats. This provides compatibility with a great range of label printers "out of the box". Conversion to other formats, if required, is left as an exercise for the plugin developer.
Expand Down
12 changes: 12 additions & 0 deletions docs/docs/extend/plugins/locate.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ If a locate plugin is installed and activated, the [InvenTree mobile app](../../
### Implementation

Refer to the [InvenTree source code](https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/plugin/samples/locate/locate_sample.py) for a simple implementation example.

### Sample Plugin

A simple example is provided in the InvenTree code base:

::: plugin.samples.locate.locate_sample.SampleLocatePlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []
12 changes: 12 additions & 0 deletions docs/docs/extend/plugins/panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ Or to add a template file that will be rendered as javascript code, from the plu

Note : see convention for template directory above.

## Sample Plugin

A sample plugin is provided in the InvenTree code base:

::: plugin.samples.integration.custom_panel_sample.CustomPanelSample
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

## Example Implementations

Refer to the `CustomPanelSample` example class in the `./plugin/samples/integration/` directory, for a fully worked example of how custom UI panels can be implemented.
Expand Down
52 changes: 9 additions & 43 deletions docs/docs/extend/plugins/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,14 @@ A plugin which implements the ReportMixin mixin can define the `add_report_conte

Additionally the `add_label_context` method, allowing custom context data to be added to a label template at time of printing.

### Example
### Sample Plugin

A sample plugin which provides additional context data to the report templates can be found [in the InvenTree source code](https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/plugin/samples/integration/report_plugin_sample.py):
A sample plugin which provides additional context data to the report templates is available:

```python
"""Sample plugin for extending reporting functionality"""

import random

from plugin import InvenTreePlugin
from plugin.mixins import ReportMixin
from report.models import PurchaseOrderReport


class SampleReportPlugin(ReportMixin, InvenTreePlugin):
"""Sample plugin which provides extra context data to a report"""

NAME = "Sample Report Plugin"
SLUG = "reportexample"
TITLE = "Sample Report Plugin"
DESCRIPTION = "A sample plugin which provides extra context data to a report"
VERSION = "1.0"

def some_custom_function(self):
"""Some custom function which is not required for the plugin to function"""
return random.randint(0, 100)

def add_report_context(self, report_instance, model_instance, request, context):

"""Add example content to the report instance"""

# We can add any extra context data we want to the report

# Generate a random string of data
context['random_text'] = ''.join(random.choices('abcdefghijklmnopqrstuvwxyz', k=20))

# Call a custom method
context['random_int'] = self.some_custom_function()

# We can also add extra data to the context which is specific to the report type
context['is_purchase_order'] = isinstance(report_instance, PurchaseOrderReport)

# We can also use the 'request' object to add extra context data
context['request_method'] = request.method
```
::: plugin.samples.integration.report_plugin_sample.SampleReportPlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []
47 changes: 8 additions & 39 deletions docs/docs/extend/plugins/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,14 @@ The ScheduleMixin class provides a plugin with the ability to call functions at
{% include 'img.html' %}
{% endwith %}

### Example
### SamplePlugin

An example of a plugin which supports scheduled tasks:

```python
class ScheduledTaskPlugin(ScheduleMixin, SettingsMixin, InvenTreePlugin):
"""
Sample plugin which runs a scheduled task, and provides user configuration.
"""

NAME = "Scheduled Tasks"
SLUG = 'schedule'

SCHEDULED_TASKS = {
'global': {
'func': 'some_module.function',
'schedule': 'H', # Run every hour
},
'member': {
'func': 'foo',
'schedule': 'I', # Minutes
'minutes': 15,
},
}

SETTINGS = {
'SECRET': {
'name': 'A secret',
'description': 'User configurable value',
},
}

def foo(self):
"""
This function runs every 15 minutes
"""
secret_value = self.get_setting('SECRET')
print(f"foo - SECRET = {secret_value})
```

!!! info "More Info"
For more information on any of the methods described below, refer to the InvenTree source code. [A working example is available as a starting point](https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/plugin/samples/integration/scheduled_task.py).
::: plugin.samples.integration.scheduled_task.ScheduledTaskPlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []
2 changes: 1 addition & 1 deletion docs/docs/extend/plugins/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The dict must be formatted similar to the following sample that shows how to use

Take a look at the settings defined in `InvenTree.common.models.InvenTreeSetting` for all possible parameters.

### Example
### Example Plugin

Below is a simple example of how a plugin can implement settings:

Expand Down
14 changes: 13 additions & 1 deletion docs/docs/extend/plugins/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ To indicate a *field* validation error (i.e. the validation error applies only t

Note that an error can be which corresponds to multiple model instance fields.

### Example
### Example Plugin

Presented below is a simple working example for a plugin which implements the `validate_model_instance` method:

Expand Down Expand Up @@ -182,3 +182,15 @@ def increment_serial_number(self, serial: str):

return val
```

## Sample Plugin

A sample plugin which implements custom validation routines is provided in the InvenTree source code:

::: plugin.samples.integration.validation_sample.SampleValidatorPlugin
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []
2 changes: 1 addition & 1 deletion docs/docs/extend/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Navigate to the "Settings" page and click on the "Display" tab, you should see t
{% include 'img.html' %}
{% endwith %}

The drop-down list let's you select any other color theme found in your static folder (see next section to find out how to [add color themes](#add-color-themes)). Once selected, click on the "Apply Theme" button for the new color theme to be activated.
The drop-down list let's you select any other color theme found in your static folder (see next section to find out how to [add color themes](#add-color-theme)). Once selected, click on the "Apply Theme" button for the new color theme to be activated.

!!! info "Per-user Setting"
Color themes are "user specific" which means that changing the color theme in your own settings won't affect other users.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/order/return_order.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ While [line items](#line-items) must reference a particular stock item, extra li

## Return Order Reports

Custom [reports](../report/return_order.md) can be generated against each Return Order.
Custom [reports](../report/templates.md) can be generated against each Return Order.

### Calendar view

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/releases/0.1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Refer to the [report documentation](../report/report.md) for further information
!!! warning "LaTeX Support"
LaTeX report templates are no longer supported for a number of technical and ideological reasons

[#1292](https://github.com/inventree/InvenTree/pull/1292) adds support for build order / work order reports. Refer to the [build report documentation](../report/build.md) for further information.
[#1292](https://github.com/inventree/InvenTree/pull/1292) adds support for build order / work order reports. Refer to the [report documentation](../report/templates.md) for further information.

### Inherited BOM Items

Expand Down
Loading
Loading