Created
August 4, 2020 21:06
-
-
Save ovnicraft/f0e50ab6e0c5548c71886b3f1398ed49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@api.one | |
def add_attachment(self, content): | |
""" | |
TODO | |
""" | |
buf = StringIO() # from io import StringIO | |
buf.write(content) | |
document = base64.encodebytes(buf.getvalue().encode()) | |
buf.close() | |
attach = self.env["ir.attachment"].create( | |
{ | |
"name": "nombre.zip", | |
"datas": document, | |
"datas_fname": "nombre.zip", | |
# "res_model": self._name, | |
# "res_id": self.id, | |
"type": "binary", | |
} | |
) | |
return attach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment