[7.0] image import fails

Bug #1244143 reported by Romain Deheele - Camptocamp
54
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Prestashop OpenERP Connector
Confirmed
Undecided
Unassigned

Bug Description

Hello,

When we import products, the image import fails.
See the next traceback:
  File "***/openerp_buildout/parts/connector/connector/queue/worker.py", line 122, in run_job
    job.perform(session)
  File "***/openerp_buildout/parts/connector/connector/queue/job.py", line 460, in perform
    self.result = self.func(session, *self.args, **self.kwargs)
  File "***/openerp_buildout/parts/prestashoperpconnect/prestashoperpconnect/unit/import_synchronizer.py", line 648, in import_record
    importer.run(prestashop_id)
  File "***/openerp_buildout/parts/prestashoperpconnect/prestashoperpconnect/unit/import_synchronizer.py", line 530, in run
    super(ProductRecordImport, self).run(prestashop_id)
  File "***/openerp_buildout/parts/prestashoperpconnect/prestashoperpconnect/unit/import_synchronizer.py", line 458, in run
    erp_id
  File "***/openerp_buildout/parts/prestashoperpconnect/prestashoperpconnect/unit/import_synchronizer.py", line 466, in _run_record
    self.mapper.convert(prestashop_record)
  File "***/openerp_buildout/parts/connector/connector/unit/mapper.py", line 221, in convert
    self._convert(record, fields=fields)
  File "***/openerp_buildout/parts/connector/connector/unit/mapper.py", line 177, in _convert
    values = meth(record)
  File "***/openerp_buildout/parts/prestashoperpconnect/prestashoperpconnect/product.py", line 193, in image
    image = adapter.read(record['id'], record['id_default_image']['value'])
  File "***/openerp_buildout/parts/prestashoperpconnect/prestashoperpconnect/unit/backend_adapter.py", line 232, in read
    options=options
  File "***/openerp_buildout/parts/prestashoperpconnect/prestashoperpconnect/unit/backend_adapter.py", line 50, in get_image
    image_content = base64.b64encode(response.content)
AttributeError: 'tuple' object has no attribute 'content'

prestashoperpconnect : rev270

Regards,

Romain

description: updated
Revision history for this message
kalmen (kalmenchia) wrote :

Hi my installed version is

prestapyt-0.5.2-py2.6 and with the connector , i managed to solve the above error and successfully
sync the product with images.

this is the patch needed , where the response[2] is the image
and the response[1] is the json string in the response of parameter 2.

backend_adapter.py from line 50 changed to below ,

        if response[2]:
            image_content = base64.b64encode(response[2])
        else:
            image_content = ''

        return {
            'type': response[1]['content-type'],
            'content': image_content,
            'id_' + resource[:-1]: resource_id,
            'id_image': image_id
        }

hope that help ,

regards,
Kalmen

Changed in prestashoperpconnect:
status: New → Confirmed
Revision history for this message
TuanNguyen (tuan-5) wrote :

Hi Kalmen,

Thanks for your solution :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.