diff --git a/uniticket/uni_ticket/forms.py b/uniticket/uni_ticket/forms.py index b2da3ceb..bc04ae9f 100644 --- a/uniticket/uni_ticket/forms.py +++ b/uniticket/uni_ticket/forms.py @@ -363,7 +363,7 @@ def __init__(self, *args, **kwargs): user = kwargs.pop("user", None) structure = kwargs.pop("structure", None) current_ticket_id = kwargs.pop("ticket_id", None) - ticket_dependences_code_list = kwargs.pop("ticket_dependences", []) + ticket_dependences_pk_list = kwargs.pop("ticket_dependences", []) ticket_id_list = [] # if user is manager/default_office operator: # he views all tickets followed by structure offices @@ -380,12 +380,12 @@ def __init__(self, *args, **kwargs): ticket_id_list = TicketAssignment.get_ticket_in_office_list( offices_list=offices_list, taken=True) - ticket_id_list = ticket_id_list.exclude(ticket__code=current_ticket_id) + ticket_id_list = ticket_id_list.exclude(ticket__pk=current_ticket_id) cleaned_list = [ - code for code in ticket_id_list if code not in ticket_dependences_code_list + pk for pk in ticket_id_list if pk not in ticket_dependences_pk_list ] ticket_list = Ticket.objects.filter( - code__in=cleaned_list, is_closed=False) + pk__in=cleaned_list, is_closed=False) super().__init__(*args, **kwargs) self.fields["ticket"].queryset = ticket_list self.fields["ticket"].to_field_name = "code" diff --git a/uniticket/uni_ticket/views/management.py b/uniticket/uni_ticket/views/management.py index e854941f..510f54be 100644 --- a/uniticket/uni_ticket/views/management.py +++ b/uniticket/uni_ticket/views/management.py @@ -572,7 +572,7 @@ def ticket_dependence_add_new( form = TicketDependenceForm( user=request.user, structure=structure, - ticket_id=ticket.code, + ticket_id=ticket.pk, ticket_dependences=ticket_dependences_code_list, ) if request.method == "POST": @@ -580,7 +580,7 @@ def ticket_dependence_add_new( request.POST, user=request.user, structure=structure, - ticket_id=ticket.code, + ticket_id=ticket.pk, ticket_dependences=ticket_dependences_code_list, ) if form.is_valid():