Odoo Ayuda

1

0
2 Respuestas
1
Sehrish Pakistán
22/6/18 1:13

Hope this helps you

attachment_ids = fields.Many2many('ir.attachment', 'class_ir_attachments_rel', 'class_id', 'attachment_id', 'Attachments')
@api.multi
def your_button_click(self):
for attachment in self.attachment_ids:
    decoded_data = base64.b64decode(attachment)
    # you logic goes here


1 Comentario
ai Suiza
25/6/18 2:36

thanks for your post.

this works:

for xml_file in self.attachment_ids:

decoded_data = base64.b64decode(xml_file.datas)

root = ElementTree.fromstring(decoded_data)

0
Avatar

Zbik Polonia

--Zbik--
12725
| 7 6 9
Łódź, Polonia
--Zbik--


Zbik Polonia
21/6/18 13:38

Try this:

for att in self.attachment_ids:
    xml = att.datas.decode('base64')
    xml_filename = att.datas_fname

1 Comentario
ai Suiza
25/6/18 2:08

thanks. I tried but does not work... LookupError: 'base64' is not a text encoding; use codecs.decode() to handle arbitrary codecs

for xml_file in self.attachment_ids:

deco_data = xml_file.datas.decode('base64')

tree = ElementTree.parse(deco_data)

root = tree.getroot()

do u know why?

Realizar una pregunta
Writer
16
ai
Keep Informed
1 seguidor(es)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now