You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
Thanks for reporting.
The error occurred in the code execution flow of the admin site, which is different from the CRM site.
Typically, projects are created by users on the CRM website. In this case, the fields next_step and next_step_date are not added to the form (but filled in automatically). Therefore, the error does not occur.
Since filling in the fields next_step and next_step_date is important for teamwork, it is better to also exclude adding these fields to the form on the admin site when creating a project (to have them filled in automatically).
This can be done in method tasks.admin.ProjectAdmin.get_fieldsets().
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
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
After making the migrations Project creation was working and the "next step" was defaulting to "Acquainted with the project"
Hope that this helps somehow!
The text was updated successfully, but these errors were encountered: