Skip to Content
Menu
This question has been flagged
3832 Zobrazenia

Hi, i am a newbe developper in Odoo12, I am actually creating a text file in attachment. Odoo seems to create this file in utf-8 format, but i need this file to be in ASCII format.


Here is my code so far :

def create_attachment(self, filename, payment_file_str):
attachment = self.env['ir.attachment'].create({
'res_model': self._name,
'res_id': self.id,
'name': filename,
'datas': base64.b64encode(payment_file_str), # base64.b64encode(payment_file_str) payment_file_str.encode('latin-1').encode('base64')
'datas_fname': filename,
})
simplified_form_view = self.env.ref(
'customer_payment_order.view_attachment_simplified_form')
action = {
'name': _('Payment File'),
'view_mode': 'form',
'view_id': simplified_form_view.id,
'res_model': 'ir.attachment',
'type': 'ir.actions.act_window',
'target': 'current',
'res_id': attachment.id,
}

return action


Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
aug 19
2122
2
nov 24
1049
0
okt 20
3080
1
mar 19
4384
2
dec 23
14543