Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
9624 Lượt xem

Hi,

I need a solution for attachments.When i attach a file(.pdf or .jpeg or .png or .doc or .xls) in attachments on top of any form, once i download that file means, it is downloaded with some other unrelated name and without file extension.Can anyone have solutions to resolve this bug.Thanks in advance.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

class myclass(osv.Model):

_name = "myclassname"

_columns = {

'binary_field':fields.binary('File'),

'file_name':fields.char('Filename'),

}

And in the form view in your xml:

<field name="filename" invisible="1"/>

<field name="binary_field" filename="file_name"/>

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can achieve this using binary fields.Binary Fields Store file encoded in base64 in bytea column in your created table.

create binary field in models.py (in your desired model)

 attachment = fields.Binary(string="Attachment")    
store_fname = fields.Char(string="File Name")

In your xml file create below fields.

<field name="store_fname" invisible="1" />
<field name="attachment" filename="store_fname"/>

 

Now when ever you will upload some file (.pdf,.xlx,.doc etc) it will be downloaded with same name and with file extension.

For more reverence visit: http://learnopenerp.blogspot.com/2016/06/using-binary-fields-in-odoo.html

Hope it helps you and others.

Thanks

Ảnh đại diện
Huỷ bỏ

For more reverence visit: http://learnopenerp.blogspot.com/2016/06/using-binary-fields-in-odoo.html

Hope it helps you and others.

Thanks

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 22
76
0
thg 6 23
2977
3
thg 6 20
8908
1
thg 5 16
6595
0
thg 4 16
6095