Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
5 Răspunsuri
6960 Vizualizări

I'm trying to make it so when an IT tech is assigned to a Helpdesk ticket, the Ticket's stage goes from 'New' to 'Assigned'.  However, when I add the tech, the stage doesn't change.  I have seen that 'onchange' doesn't work in the event that you have a clickable Statusbar widget, which we have set up for our tickets.  Unfortunately, I haven't seen a good workaround, but perhaps I'm missing something.  Can anyone give me some suggestions?

@api.onchange('user_id')
def tmg_assigned_user_id(self)
        self.ensure_one()
        for ticket in self:
                if ticket.user_id:
                    ticket.stage_id.sequence = 1

Imagine profil
Abandonează

Why are you changing the sequence of the stage_id? What happens if you just change the stage_id to 1? (Also, tip: Ideally you should SEARCH for the Assigned status to make sure you have the correct ID)

Autor

We wanted to make the stage change automatically when a tech is assigned to a ticket, so that way, the ticket status just doesn't stay as 'New'. If I just change the stage_id to 1, nothing happens as well. Our 'Assigned' status is under sequence 1, while 'New' is 0 and so on

I understand what you want to do, I just wanted to point out that what your code is trying to do is change the sequence of the stage, not change the stage. Seems like you've tried ticket.stage_id = {something} also?

Autor

Thanks for bringing that up. I actually did just notice that today. I didn't realize that's what was happening. I have tried ticket.stage_id = 'In Progress' but unfortunately to no avail. I think this also just ended up changing the ticket status name in sequence 0 to "In Progress"

Autor Cel mai bun răspuns

@subbarao

I wasn't able to get it to work.  It must be my logic at this point.

@api.multi
def write(self,vals):
      if vals.get('user_id'):
           vals['stage_id] = 1
      return super(HelpdeskTicket, self).write(vals)
Imagine profil
Abandonează
Autor

I actually was able to get this to work. The write method also needed the create method to go along with it. Turns out my code was right after all. Thanks for the help

Autor

The create method looks exactly the same but just has @api.model instead

Cel mai bun răspuns

Hello Andrew,

Instead of doing it on onchange use write method.

@api.multi

def write(self, vals):

    if vals.get('user_id',False):

    ###        write your logic here

    return super(your_class_name, self).write(vals)



Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
4
mar. 20
154
2
sept. 16
13491
1
mar. 15
7358
1
iul. 23
10610
0
apr. 16
5336