Notification Mixin
NotificationMixin¶
The NotificationMixin class provides a plugin with the ability to send notifications to users when certain events occur in the system.
Any notification which is generated by the InvenTree core system can be sent to users via a custom plugin which implements this mixin class.
send_notification¶
The send_notification method is used to send a notification to users:
Send notification to the specified target users.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Model
|
The target model instance to which the notification relates. |
required |
category
|
str
|
The category of the notification. |
required |
users
|
list
|
List of users to send the notification to. |
required |
context
|
dict
|
Context data for the notification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the notification was sent successfully, False otherwise. |
Source code in src/backend/InvenTree/plugin/base/integration/NotificationMixin.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
filter_targets¶
If desired, the plugin can implement the filter_targets method to filter the list of users who will receive the notification. This allows for more granular control over which users are notified based on specific criteria.
Filter notification targets based on the plugin's logic.
Source code in src/backend/InvenTree/plugin/base/integration/NotificationMixin.py
35 36 37 38 | |
Built-in Notifications¶
The following built-in notifications plugins are available: