Decodificar base64 en Odoo 12
angiielovee177 at gmail.com
angiielovee177 at gmail.com
Tue Mar 5 18:16:18 EST 2019
El martes, 5 de marzo de 2019, 3:05:07 (UTC-6), Peter Otten escribió:
> angiielovee177 at gmail.com wrote:
>
> > El lunes, 4 de marzo de 2019, 11:07:40 (UTC-6), Peter Otten escribió:
> >> Angie GL wrote:
> >>
> >> > Hola a todos, tengo un problema al decodificar el contenido de una
> >> > variable base64.
> >> >
> >> > De esta manera lo hago:
> >> >
> >> > cfdi = base64.b64decode(inv.l10n_mx_edi_cfdi)
> >> >
> >> >
> >> >
> >> > Al momento de decodificar el resultado que me envía es esto:
> >> >
> >> > b'\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'
> >> >
> >> > Alguien que me pueda decir que estoy haciendo mal, lo cheque en la
> >> > consola Python3 y todo va bien, pero dentro de Odoo no lo decodifica.
> >>
> >> What result did you expect?
> >>
> >> What is the value of inv.l10n_mx_edi_cfdi? For
> >>
> >> b'CgogCiAKIAogCiAKIAogCiAKIAogCiAKIAogCiAKIAogCgo='
> >>
> >> you see the correct result:
> >>
> >> >>> base64.b64decode(b'CgogCiAKIAogCiAKIAogCiAKIAogCiAKIAogCiAKIAogCgo=')
> >> b'\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'
> >
> > El valor de la variable inv.l10n_mx_edi_cfdi es una factura en formato
> > base64, el resultado que espero es que decodifique la factura para
> > posteriormente mostrarlo. PERO NO LO DECODIFICA,ya verifique el valor de
> > la variable pero no lo hace.
>
> If you replace the line
>
> >> > cfdi = base64.b64decode(inv.l10n_mx_edi_cfdi)
>
> in your script with
>
> cfdi = inv.l10n_mx_edi_cfdi
> print(type(cfdi))
> print(repr(cfdi))
> cfdi = base64.b64decode(cdfi)
> print(repr(cfdi))
>
> what gets printed? Use cut and paste to post the result. If there is a
> traceback post that, too. Thank you.
Este es el resultado de cada linea:
> cfdi = inv.l10n_mx_edi_cfdi
> print(type(cfdi)) No imprime nada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Dg3IiBVbmlkYWQ9IlVuaWRhZChlcykiIERlc2NyaXBjaW9uPSJbQ09OXSBDb25zdWx0b3JpYSIgVmFsb3JVbml0YXJpbz0iMjAwMC4wMCIgSW1wb3J0ZT0iNDAwMC4wMCI+CiAgICAgIDxjZmRpOkltcHVlc3Rvcz4KICAgICAgICA8Y2ZkaTpUcmFzbGFkb3M+CiAgICAgICAgICA8Y2ZkaTpUcmFzbGFkbyBCYXNlPSI0MDAwLjAwIiBJbXB1ZXN0bz0iMDAyIiBUaXBvRmFjdG9yPSJUYXNhIiBUYXNhT0N1b3RhPSIwLjE2MDAwMCIgSW1wb3J0ZT0iNjQwLjAwIi8+CiAgICAgICAgPC9jZmRpOlRyYXNsYWRvcz4KICAgICAgPC9jZmRpOkltcHVlc3Rvcz4KICAgIDwvY2ZkaTpDb25jZXB0bz4KICA8L2NmZGk6Q29uY2VwdG9zPgogIDxjZmRpOkltcHVlc3RvcyBUb3RhbEltcHVlc3Rvc1RyYXNsYWRhZG9zPSI2NDAuMDAiPgogICAgPGNmZGk6VHJhc2xhZG9zPgogICAgICA8Y2ZkaTpUcmFzbGFkbyBJbXBvcnRlPSI2NDAuMDAiIEltcHVlc3RvPSIwMDIiIFRpcG9GYWN0b3I9IlRhc2EiIFRhc2FPQ3VvdGE9IjAuMTYwMDAwIi8+CiAgICA8L2NmZGk6VHJhc2xhZG9zPgogIDwvY2ZkaTpJbXB1ZXN0b3M+CjwvY2ZkaTpDb21wcm9iYW50ZT4=')
> cfdi = base64.b64decode(cdfi)
> print(repr(cfdi)) Imprime b'\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'
Intente con otra cadena en base64 y lo hace bien, al momento de que sea una factura no lo hace. ¿Qué podrá ser?, llevo días tratando de resolver este problema y solo no veo solución.
More information about the Python-list
mailing list