Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
2240 Zobrazení

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

* we are using odoo online.

Avatar
Zrušit
Autor Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit

I think that this is not possible with Odoo Online

Related Posts Odpovědi Zobrazení Aktivita
0
dub 17
3916
1
srp 25
188
0
bře 25
1613
0
říj 24
1556
1
zář 24
1680