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

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

アバター
破棄
関連投稿 返信 ビュー 活動
0
6月 25
2643
0
8月 19
2546
2
7月 25
419
0
1月 25
698
2
8月 24
5384