Hi,
How can I read content of binary field in Odoo8.
I added a fileds.Binary in my model and can browse file in view but I can't read It content.
Please to give an exemple about how to browse a file and read It content in Odoo8 ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
How can I read content of binary field in Odoo8.
I added a fileds.Binary in my model and can browse file in view but I can't read It content.
Please to give an exemple about how to browse a file and read It content in Odoo8 ?
hii Omar OUHARI ,
below code help to read content of file after browse. and file is my fields.binary field. hope so this will help you.
base64.encodestring(args.get('file').read())
Hello Omar,
I see that your post is from 2015, but I had the same problem in 2019 :)
However I found a solution and I'm sharing it for someone who is experiencing the same issue.
In Ir_http.py there is a method called binary_content, which returns a binary field content and some other info. You can use it in any model or controller with the following import:
from odoo.addons.web.controllers.main import binary_content
* Tested on Odoo 11 Community version
Regards,
Lyubo.
Hi,
this is what worked for me:
with io.BytesIO(base64.b64decode(self.binary_field_name)) as f:
# do stuff with the contents here as if it were a file
Best regards,
David
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Ol| İlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
|---|---|---|---|---|
|
2
Tem 20
|
28819 | |||
|
2
Ara 23
|
26168 | |||
|
1
Mar 15
|
4042 | |||
|
0
Mar 15
|
4723 | |||
|
1
Mar 15
|
4767 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.
could you please give more details, did you meant about reading values from text file?