gentextfile = fields.Binary(string='Text File')
file = open("sampletext.txt", 'w')
file.write("Hello World")
file.close()
How can I save it to the Binary Field declared?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
gentextfile = fields.Binary(string='Text File')
file = open("sampletext.txt", 'w')
file.write("Hello World")
file.close()
How can I save it to the Binary Field declared?
Hello Dee Yoj,
Please check below code. I hope it will work.
E.g:
Take two fields in .py file like below:
import base64
name : fields.Char(string='Name', size=64)
gentextfile : fields.Binary('Click On Save As Button To Download File', readonly=True)
In .xml file:
<group>
<field name="name" invisible="1" />
<field name="gentextfile" filename="name"/>
</group>
write or Save your .txt file in binary field:
file = open("sampletext.txt", "rb")
out = file.read()
file.close()
gentextfile = base64.b64encode(out)
name = 'sampletext.txt'
OR
record_set.write({'gentextfile': base64.b64encode(out), 'name': 'sampletext.txt'})
Thanks
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
3
Feb 25
|
3484 | ||
|
0
Mei 24
|
46 | ||
|
1
Apr 24
|
3323 | ||
|
4
Sep 23
|
4807 | ||
|
2
Sep 23
|
7025 |
Reference: http://learnopenerp.blogspot.com/2016/06/using-binary-fields-in-odoo.html