تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5621 أدوات العرض

with open('WHOUSE.txt', 'r') as f_read:
            file_data = f_read.read()
            print 'file_data', file_data
            data_encode = file_data.encode('utf8').encode('base64')
            data_decode = data_encode.decode('base64','strict')
            print 'data_decode',data_decode

        values = {
            'name': 'WHOUSE.txt',
            'datas_fname': 'WHOUSE.txt',
            'res_model': 'ir.ui.view',
            'res_id': False,
            'type': 'binary',
            'public': True,
            'datas': data_decode,

        }


I think i have a problem in decoding, I don't which part and what do I do.

الصورة الرمزية
إهمال
أفضل إجابة

Hello Dee Yoj,    

I think you need to pass encoded data in values as below,

You can try below code 

Hope this will help you

 values = {
            'name': 'WHOUSE.txt',
            'datas_fname': 'WHOUSE.txt',
            'res_model': 'ir.ui.view',
            'res_id': False,
            'type': 'binary',
            'public': True,
            'datas': data_encode,
        }

الصورة الرمزية
إهمال
الكاتب

this is my first code, but when I download the txt file all the text are in one line only.. I put \n in each line but still when I download it, it's in one line.

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
نوفمبر 17
9166
1
يناير 23
6309
1
مارس 21
18883
0
سبتمبر 17
5351
0
فبراير 16
5131