diff --git a/InvenTree/common/notifications.py b/InvenTree/common/notifications.py index 9151f9b879..fe737fc919 100644 --- a/InvenTree/common/notifications.py +++ b/InvenTree/common/notifications.py @@ -154,11 +154,18 @@ class UIMessageNotification(SingleNotificationMethod): return True -def trigger_notifaction(obj, category=None, obj_ref='pk', targets=None, target_fnc=None, target_args=[], target_kwargs={}, context={}): +def trigger_notifaction(obj, category=None, obj_ref='pk', **kwargs): """ Send out a notification """ + targets = kwargs.get('targets', None) + target_fnc = kwargs.get('target_fnc', None) + target_args = kwargs.get('target_args', []) + target_kwargs = kwargs.get('target_kwargs', {}) + context = kwargs.get('context', {}) + delivery_methods = kwargs.get('delivery_methods', None) + # Check if data is importing currently if isImportingData(): return @@ -190,7 +197,8 @@ def trigger_notifaction(obj, category=None, obj_ref='pk', targets=None, target_f logger.info(f"Sending notification '{category}' for '{str(obj)}'") # Collect possible methods - delivery_methods = inheritors(NotificationMethod) + if delivery_methods is None: + delivery_methods = inheritors(NotificationMethod) for method in [a for a in delivery_methods if a not in [SingleNotificationMethod, BulkNotificationMethod]]: logger.info(f"Triggering method '{method.METHOD_NAME}'") diff --git a/InvenTree/plugin/events.py b/InvenTree/plugin/events.py index 7a2e0d2da3..ac0eaf3914 100644 --- a/InvenTree/plugin/events.py +++ b/InvenTree/plugin/events.py @@ -233,4 +233,5 @@ def print_label(plugin_slug, label_image, label_instance=None, user=None): 'label.printing_failed', targets=[user], context=ctx, + delivery_methods=[common.notifications.UIMessageNotification] )