تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3147 أدوات العرض

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
أبريل 25
1406
1
مارس 23
2773
1
مارس 22
1357
0
فبراير 19
2930
1
يوليو 25
1597