Skip to Content
Menu
This question has been flagged
2 Replies
6056 Rodiniai

I upload the image in this i need to allow only the png image others will not be allowed?How to do that

Portretas
Atmesti
Best Answer

if attachment_line.file_name and attachment_line.file_name.lower (). endswith (('. png' )):

                    self.env ['ir.attachment']. create ({

                        'name': attachment_line.file_name,

                        'attachment_type': attachment_line.type,

                        'datas': attachment_line.attachment,

                        'status': 'to_approve',

                        'datas_fname': attachment_line.file_name,

                        'res_id': active_rec.sale_line_id.id,

                        'res_model': 'sale.order.line'

                    })

                else:

                    raise UserError (_ ("Sorry! Only .png is the Supported Format.") )


accept and upvote if useful

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
0
birž. 25
2768
0
rugp. 19
2631
2
liep. 25
584
0
saus. 25
816
2
rugp. 24
5549