Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
2070 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 17
3718
0
มี.ค. 25
1429
0
ต.ค. 24
1411
1
ก.ย. 24
1542
1
ส.ค. 24
1645