Odoo Help

0

filename of field binary not worked , it is encoded

By
Marwa ROMDHAN
on 8/1/17, 9:05 AM 1,074 views

Hi

I Have in my wizard:

datas = fields.Binary('File')
filename = fields.Char('File Name')

and in .xml :

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

But the field datas always has a string encoded






Cordialement,
Marwa ROMDHAN
Diplôme Ingénieur Informatique option Génie Logiciel de l'ENIS promotion 2013
Consultante Technico-Fonctionnel Odoo (3 ans d’expérience)
Tel: (+216) 55 010 671  
Skype marwa.romdhan
Facebook LinkedIn Google Plus Page 

2017-08-02 5:33 GMT+01:00 Avinash Nk <avinashnk916@gmail.com>:

A new answer on filename of field binary not worked , it is encoded has been posted. Click here to access the post :

See post

--
Avinash Nk


Sent by Odoo S.A. using Odoo.


Marwa ROMDHAN
on 8/2/17, 5:29 AM
0
Sarender Reddy
On 12/18/17, 9:13 AM


<field name="datas" filename="filename" />

TO

<field name="datas"  widget="binary"  filename="filename" />

sure........ it will work.

0
Marwa ROMDHAN
On 8/2/17, 5:30 AM

Thanks for your response,

But I mean, In My view form I don't have the file name .

I have the content of file decoded !! I would appear the file name

0

Avinash Nk

--Avinash Nk--

2051
| 4 3 6
Calicut, India
--Avinash Nk--

 

Avinash Nk
On 8/2/17, 12:33 AM

Hi marwa,
      
         The file_name field contains the name of the file you are uploading.
          
         The datas field contains the file you are uploading.
 
For decoding that file, you can use base64decoding. 

import base64
from odoo import api, fields, models

class YourClass(models.TransientModel):
_name = 'your.wizard'

datas = fields.Binary(string="File")
file_name = fields.Char(string="File Name")

@api.multi
def your_function(self):
file_encoded = base64.b64decode(self.datas)

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 8/1/17, 9:05 AM
Seen: 1074 times
Last updated: 12/18/17, 9:13 AM