Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
215 Widoki

I have added a new module to my Odoo 18, which opens the form to create a new helpdesk ticket. Which is what I wanted, the only thing I would like to modify is that the user, which creates the ticket, is automatically assigned to the ticket. Is that possible?


 

Thanks for any advice

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,


It's possible and straightforward to automatically assign the current user as the ticket creator when a new helpdesk ticket is made in Odoo 18


You can achieve this in your custom module by overriding the create() method of the helpdesk.ticket model.


from odoo import models, api


class HelpdeskTicket(models.Model):

    _inherit = 'helpdesk.ticket'


    @api.model

    def create(self, vals):

        # Assign current user if not already set

        if not vals.get('user_id'):

            vals['user_id'] = self.env.uid

        return super(HelpdeskTicket, self).create(vals)



If the ticket is being created without a specific assignee, it defaults to the logged-in user.


Hope it helps

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
5
sie 24
2549
0
sty 22
2335
1
mar 25
4330
1
wrz 21
5996
0
mar 18
3795