콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
2190 화면

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
3863
0
3월 25
1574
0
10월 24
1522
1
9월 24
1660
1
8월 24
1774