I like to create a small automated action with this code:
attachment = env['ir.attachment'].search_read([['res_id', '=', record.id]])
pdf = attachment[0].get("datas")
file = open("/odoo/sample.pdf", "wb")
file.write(pdf)
file.close()
but i get the error "open is not defined". Why could i not use the build-in open() function?