Skip to Content
Menu
This question has been flagged
1 Reply
568 Views

Hi,

We need to restrict closure of helpdesk ticket to customers, the main setting is enabled but the support staff or the staff to whom the ticket is assigned can close it. I want to try doing it through record rules to restrict the closure by customers only.


Thanks & Best Regards,


Avatar
Discard
Best Answer

Hi,

Please refer to the code:

from odoo import models, fields, api

from odoo.exceptions import UserError


class HelpdeskTicket(models.Model):

    _inherit = 'helpdesk.ticket'


    @api.constrains('stage_id')

    def _check_close_by_customer(self):

        for ticket in self:

            if ticket.stage_id.is_close and self.env.user.has_group('base.group_user'):

                # staff/internal user trying to close

                raise UserError("Only the customer can close this ticket.")


Hope it helps.

Avatar
Discard
Related Posts Replies Views Activity
1
Apr 25
721
1
Aug 25
547
0
Mar 25
1906
0
Oct 24
1891
1
Sep 24
1984