Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8206 Lượt xem

Hope all stack members are alright .I am able to fetch binary data of Product image using code

p_ids=self.env.context.get('active_ids')
produtc_templates = self.env['product.template']
for p_id in p_ids:
 binaryData = produtc_templates.search([('id', '=',p_id)]).image 
 data=base64.b64decode(binaryData)
        file="marketplaces/rakuten_ftp/static/imageToSave_"+str(p_id)+".png"
        with open(file, "wb") as imgFile:
            imgFile.write(data)

Above code is create files from binary Data But i am failed to apply condition on mimetype base.Because when i query ir_attachment table with Products id's it return me False.

for p_id in p_ids:
 attachments = self.env['ir.attachment']
 mimetype=attachments.search([('res_id','=',p_id)])

I am considering res_id as Product id .But odoo failed to find any record against that id.So if any body have idea that how i can get mimetype against my product id then please help me.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can look here

https://www.odoo.com/forum/help-1/question/where-are-document-attachments-stored-529

This is included in an official documentation

Ảnh đại diện
Huỷ bỏ
Tác giả

I am failed to find mimetype against product id in ir_attachement.

product_images = self.env['ir.attachment'].search([('res_id', 'in', p_ids)

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 6 18
17248
2
thg 4 19
5123
2
thg 10 24
945
2
thg 7 24
1595
1
thg 6 24
4132