콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3398 화면

What would be the most efficient strategy to import product images into a V15 db when the original product images are stored into a v14 db?

I know how to import and export data using  Odoo dedicated menus. 

However as images as concerned the export seems to geneate cell contents that are to long to be 100% exported; preventing reimport with 100% success.

Any direction on how to do this transfer from one odoo db to another one will be helpful.


아바타
취소
베스트 답변

Hi  Thomas,

I think this video can help you: https://www.youtube.com/watch?v=VMJ0UI1crz4&list=PLSKcWRTtEl5qzvRaI-VTGavfReiHS_EEb&index=3

아바타
취소
베스트 답변

Hi

First, you export the images field with the external id, eg you need to move the employee's images from v14 to 15
try to export the external id and the image filed and after you must write a wizard action and try to put the below code into it 

from odoo import models, fields
import base64
import io
import csv


class DynamicField(models.TransientModel):
_name = 'import.photo'
_description = 'Import Photo'

file = fields.Binary('File')

def import_photo(self):

csv_data = base64.b64decode(self.file)

data_file = io.StringIO(csv_data.decode("utf-8"))

csv_reader = csv.reader(data_file, delimiter=',')
keys = ['id', 'photo']
file_reader = []
file_reader.extend(csv_reader)
for i in range(len(file_reader)):
field = list(map(str, file_reader[i]))
values = dict(zip(keys, field))
if values:
if i == 0:
continue
else:
employee = self.env.ref(values['id'])
employee.write({
'image_1920': values['photo']
})

XML:

<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record model='ir.ui.view' id='wizard_employee_photo_import'>
 
      <field name="name">import.photo</field>
        <field name="model">import.photo</field>
        <field name="arch" type="xml">
            <form string="Import">
                <sheet>
                    <group>
                        <group string="Import">
                            <field name="file"/>
                        </group>
                    </group>
                </sheet>
                <footer>
                    <button name="import_photo" string="Import" type="object" class="oe_highlight"/>
                    or
                    <button string="Cancel" class="oe_link" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>


Hope it helps

아바타
취소
관련 게시물 답글 화면 활동
1
4월 25
1681
1
3월 23
2999
1
3월 22
1608
0
2월 19
3176
1
7월 25
2058