Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. def send_mail_invoice(self, cr, uid, obj, xml_element, auth, context=None):
  2. self.write(cr, uid, [obj.id], {
  3. 'numero_autorizacion': auth.numeroAutorizacion,
  4. 'estado_autorizacion': auth.estado,
  5. 'ambiente': auth.ambiente,
  6. 'fecha_autorizacion': auth.fechaAutorizacion.strftime("%d/%m/%Y %H:%M:%S"),
  7. 'autorizado_sri': True
  8. })
  9. einvoice_xml = etree.tostring(xml_element, pretty_print=True, encoding='iso-8859-1')
  10. buf = StringIO.StringIO()
  11. buf.write(einvoice_xml)
  12. einvoice = base64.encodestring(buf.getvalue())
  13. buf.close()
  14. attachment_id = self.pool.get('ir.attachment').create(cr, uid,
  15. {
  16. 'name': '{0}.xml'.format(obj.clave_acceso),
  17. 'datas': einvoice,
  18. 'datas_fname': '{0}.xml'.format(obj.clave_acceso),
  19. 'res_model': self._name,
  20. 'res_id': obj.id,
  21. 'type': 'binary'
  22. }, context=context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement