Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
2039 Visualizzazioni

User how to restrict specific file extension to upload on the odoo online ticketing system attachement form ?

* we are using odoo online.

Avatar
Abbandona
Autore Risposta migliore

please show me on how i can do it with the below code.

Avatar
Abbandona
Risposta migliore

To restrict specific file extensions as attachment on the helpdesk.ticket model, you can override the create and write methods of this object. 


class HelpdeskTicket(models.Model):
    _inherit = 'helpdesk.ticket'

    @api.model
    def create(self, values):
        attachments = values.get('attachment_ids', [])
        for attachment in attachments:
            datas_fname = attachment[2].get('datas_fname', '')
            if datas_fname.endswith(('.exe', '.bat')):
                raise ValidationError('You cannot upload files with .exe or .bat extensions.')
        return super(HelpdeskTicket, self).create(values)

I've used '.exe' and '.bat' as an example, you can add the extensions you want and then in the same manner define a write method and I hope this should solve your problem. 




Avatar
Abbandona

I think that this is not possible with Odoo Online

Post correlati Risposte Visualizzazioni Attività
0
apr 17
3700
0
mar 25
1413
0
ott 24
1382
1
set 24
1535
1
ago 24
1636