diff --git a/InvenTree/common/serializers.py b/InvenTree/common/serializers.py index 3bec482ff6..3ff2fc803a 100644 --- a/InvenTree/common/serializers.py +++ b/InvenTree/common/serializers.py @@ -161,8 +161,8 @@ class NotificationMessageSerializer(InvenTreeModelSerializer): """Function to resolve generic object reference to target.""" target = get_objectreference(obj, 'target_content_type', 'target_object_id') - if 'link' not in target: - # Check if objekt has an absolute_url function + if target and 'link' not in target: + # Check if object has an absolute_url function if hasattr(obj.target_object, 'get_absolute_url'): target['link'] = obj.target_object.get_absolute_url() else: @@ -174,6 +174,7 @@ class NotificationMessageSerializer(InvenTreeModelSerializer): f'admin:{meta.db_table}_change', kwargs={'object_id': obj.target_object_id} )) + return target def get_source(self, obj): diff --git a/InvenTree/templates/js/translated/notification.js b/InvenTree/templates/js/translated/notification.js index c497755f40..c511010b5c 100644 --- a/InvenTree/templates/js/translated/notification.js +++ b/InvenTree/templates/js/translated/notification.js @@ -174,6 +174,12 @@ function updateNotificationReadState(btn, panel_caller=false) { } else { count = count + 1; } + + // Prevent negative notification count + if (count < 0) { + count = 0; + } + // update notification indicator now updateNotificationIndicator(count);