There is no setting to do so. You could probably tinker something with the API and webhooks so that it autoupdates the name after creation.
On the other hand, if you are talking about the numerical id that appears on every item (as in #53), they are sequential so you should be able to guess them beforehand, depending on the number of items and how many people are working on the given project.
You could, for example, add a check in the save method (here it is for user stories). That executes every time an object is created or updated, so it’s best to have something like if not self.ref in self.subject or something like that to check before.
Of course, there are other ways to do it, like creating a service for example, and then calling it somewhere else in the code.
def save(self, *args, **kwargs):
if not self.ref in self.subject:
self.subject = self.ref + self.subject
if not self.\_importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.status_id:
self.status = self.project.default_issue_status
if not self.type_id:
self.type = self.project.default_issue_type
if not self.severity_id:
self.severity = self.project.default_severity
if not self.priority_id:
self.priority = self.project.default_priority
return super().save(\*args, \*\*kwargs)
and
def save(self, *args, **kwargs):
if not self.ref in self.subject:
self.subject = f’{self.ref} {self.subject}’
if not self.\_importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.status_id:
self.status = self.project.default_issue_status
if not self.type_id:
self.type = self.project.default_issue_type
if not self.severity_id:
self.severity = self.project.default_severity
if not self.priority_id:
self.priority = self.project.default_priority
return super().save(\*args, \*\*kwargs)
which caused updating and creation to fail.
The changes I made looks like standard python/Django to me.
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.