Hi there, Keith!
I checked the code again just in case, and the ref value is auto generated in a post save signal (so it is not available before the save). You can either do it after the save, or globally on this method, something like this:
// ...existing code...
def attach_sequence(sender, instance, created, **kwargs):
if not instance._importing:
if created or instance.prev_project != instance.project:
# Create a reference object. This operation should be
# used in transaction context, otherwise it can
# create a lot of phantom reference objects.
refval, _ = make_reference(instance, instance.project)
# Additionally, attach sequence number to instance as ref
instance.ref = refval
# Add ref prefix to subject if not already present
if hasattr(instance, 'subject') and not instance.subject.startswith(f"{refval} "):
instance.subject = f"{refval} {instance.subject}"
instance.save(update_fields=['ref', 'subject'])
else:
instance.save(update_fields=['ref'])
That would affect all instance types, though: Issue, Task, Epic and User Story. I did a quick try and it seems to work, let me know if that works for you.
Best!