コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
2072 ビュー

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

* we are using odoo online.

アバター
破棄
著作者 最善の回答

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

アバター
破棄
最善の回答

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. 




アバター
破棄

I think that this is not possible with Odoo Online

関連投稿 返信 ビュー 活動
0
4月 17
3727
0
3月 25
1433
0
10月 24
1414
1
9月 24
1542
1
8月 24
1645