Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
5986 Представления

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

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
июн. 25
2638
0
авг. 19
2540
2
июл. 25
392
0
янв. 25
695
2
авг. 24
5377