Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def send_mail_invoice(self, cr, uid, obj, xml_element, auth, context=None):
- self.write(cr, uid, [obj.id], {
- 'numero_autorizacion': auth.numeroAutorizacion,
- 'estado_autorizacion': auth.estado,
- 'ambiente': auth.ambiente,
- 'fecha_autorizacion': auth.fechaAutorizacion.strftime("%d/%m/%Y %H:%M:%S"),
- 'autorizado_sri': True
- })
- einvoice_xml = etree.tostring(xml_element, pretty_print=True, encoding='iso-8859-1')
- buf = StringIO.StringIO()
- buf.write(einvoice_xml)
- einvoice = base64.encodestring(buf.getvalue())
- buf.close()
- attachment_id = self.pool.get('ir.attachment').create(cr, uid,
- {
- 'name': '{0}.xml'.format(obj.clave_acceso),
- 'datas': einvoice,
- 'datas_fname': '{0}.xml'.format(obj.clave_acceso),
- 'res_model': self._name,
- 'res_id': obj.id,
- 'type': 'binary'
- }, context=context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement