Open
Description
Hi! I've been trying to use the Tasks feature to create new Projects and I was getting this error:
The error happens on the method below, on tasks/site/tasksbasemodeladmin.py
def save_model(self, request, obj, form, change):
if "next_step" in form.changed_data:
if obj.responsible.count() == 1 and obj.responsible.get() != request.user:
obj.next_step += f" ({request.user})"
obj.add_to_workflow(f'{obj.next_step}.')
if "next_step_date" in form.changed_data:
if (
all((obj.next_step_date, obj.due_date))
and obj.next_step_date > obj.due_date
):
html_msg = (
get_trans_for_user(NEXT_STEP_DATE_WARNING, request.user)
+ f'<a href="{obj.get_absolute_url()}"> {obj.name} ({obj.owner})</a>'
)
save_message(request.user, html_msg, "INFO")
super().save_model(request, obj, form, change)
From what I gather, when entering the very first if check, the logic within tries to perform a relational operation of this object with another, but this object we are trying to save doenst quite exists yet, so we cannot access it's "ID" field.
I've created a workaround setting the model to allow blank values, this way I can avoid this condition altogether
next_step = models.CharField(
max_length=250,
verbose_name=_("Next step"),
help_text=_("Describe briefly what needs to be done in the next step."),
blank=True,
)
After making the migrations Project creation was working and the "next step" was defaulting to "Acquainted with the project"
Hope that this helps somehow!