diff --git a/netbox/extras/api/serializers_/events.py b/netbox/extras/api/serializers_/events.py index 4285b12e6..469da3e8c 100644 --- a/netbox/extras/api/serializers_/events.py +++ b/netbox/extras/api/serializers_/events.py @@ -47,8 +47,7 @@ class EventRuleSerializer(NetBoxModelSerializer): # We need to manually instantiate the serializer for scripts if instance.action_type == EventRuleActionChoices.SCRIPT: script = instance.action_object - instance = script.python_class() if script.python_class else None - return ScriptSerializer(instance, nested=True, context=context).data + return ScriptSerializer(script, nested=True, context=context).data else: serializer = get_serializer_for_model(instance.action_object_type.model_class()) return serializer(instance.action_object, nested=True, context=context).data diff --git a/netbox/extras/events.py b/netbox/extras/events.py index a33ac213c..34d2ec159 100644 --- a/netbox/extras/events.py +++ b/netbox/extras/events.py @@ -118,7 +118,7 @@ def process_event_rules(event_rules, model_name, event, data, username=None, sna # Enqueue a Job to record the script's execution Job.enqueue( "extras.scripts.run_script", - instance=script.module, + instance=event_rule.action_object, name=script.name, user=user, data=data