[7.0 trunk] Exception loading data into new DB - partner image

Bug #1048040 reported by tozm
28
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
OpenERP's Framework R&D

Bug Description

Have created a fresh openerp dev environment on Windows, using Python 2.7.3 and all latest python packages used by OpenERP.

Pulled trunk of server/addon/web. Server @4403.

Creating fresh database, I get the following exception, and I note there have been some very recent changes to the avatar stuff.

2012-09-09 08:33:00,430 5528 INFO test openerp.modules.loading: module base: loading objects
2012-09-09 08:33:00,519 5528 INFO test openerp.modules.module: module base: creating or updating database tables
2012-09-09 08:33:07,388 5528 INFO test openerp.modules.loading: module base: loading base_data.xml
2012-09-09 08:33:09,219 5528 ERROR test openerp.tools.convert: Parse error in file:///C:/dev/workspace/openobject-server/openerp/addons/base/base_data.xml:1057:
<record id="main_partner" model="res.partner" context="{'default_is_company': True}">
            <field name="name">Your Company</field>
            <field name="company_id" eval="None"/>
            <field name="customer" eval="False"/>
            <field name="is_company" eval="True"/>
            <field name="street"/>
            <field name="city"/>
            <field name="zip"/>
            <field name="phone"/>
            <field name="email"><email address hidden></field>
            <field name="website">www.yourcompany.com</field>
        </record>
Traceback (most recent call last):
  File "C:\dev\workspace\openobject-server\openerp\tools\convert.py", line 858, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "C:\dev\workspace\openobject-server\openerp\tools\convert.py", line 825, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "C:\dev\workspace\openobject-server\openerp\addons\base\ir\ir_model.py", line 814, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "C:\dev\workspace\openobject-server\openerp\addons\base\res\res_partner.py", line 337, in create
    return super(res_partner,self).create(cr, uid, vals, context=context)
  File "C:\dev\workspace\openobject-server\openerp\osv\orm.py", line 4324, in create
    self.pool.get(object)._store_set_values(cr, user, ids, fields2, context)
  File "C:\dev\workspace\openobject-server\openerp\osv\orm.py", line 4446, in _store_set_values
    result = self._columns[val[0]].get(cr, self, ids, val, SUPERUSER_ID, context=context)
  File "C:\dev\workspace\openobject-server\openerp\osv\fields.py", line 1117, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "C:\dev\workspace\openobject-server\openerp\addons\base\res\res_partner.py", line 144, in _get_image
    result[obj.id] = tools.image_get_resized_images(obj.image)
  File "C:\dev\workspace\openobject-server\openerp\tools\image.py", line 138, in image_get_resized_images
    if return_medium: return_dict[medium_name] = image_resize_image_medium(base64_source)
  File "C:\dev\workspace\openobject-server\openerp\tools\image.py", line 94, in image_resize_image_medium
    return image_resize_image(base64_source, size, encoding, filetype)
  File "C:\dev\workspace\openobject-server\openerp\tools\image.py", line 60, in image_resize_image
    image = Image.open(image_stream)
  File "C:\Tools\Python27\lib\site-packages\PIL\Image.py", line 1980, in open
    raise IOError("cannot identify image file")
IOError: cannot identify image file
2012-09-09 08:33:09,374 5528 INFO test werkzeug: 127.0.0.1 - - [09/Sep/2012 08:33:09] "GET / HTTP/1.1" 200 -

Related branches

Revision history for this message
Houssine (houssine-bakkali) wrote :

it seems that the call to this function in res_partner.py gives the error

def _get_default_image(self, cr, uid, is_company, context=None, colorize=False):
        if is_company:
            image = open(openerp.modules.get_module_resource('base', 'static\src\img', 'company_image.png')).read()
        else:
            image = tools.image_colorize(open(openerp.modules.get_module_resource('base', 'static/src/img', 'avatar.png')).read())
        return tools.image_resize_image_big(image.encode('base64'))

it's something with the image open().read that is wrong the str sent to the tools.image_resize_image_big(image.encode('base64')) function seems weird

anyway if you want to be able to create a database you should comment the call to the function while this is causing problem... I don't know if it happens only under windows environment as I have also run this under windows in a eclipse dev env.

Hope it will help!

Cheers,
Houssine

Revision history for this message
Anil Saraswathy (anilgs) wrote :

The problem is with the file open call. Since these are binary files, you need to specify read-binary mode as follows:
image = open(openerp.modules.get_module_resource('base', 'static/src/img', 'company_image.png'), 'rb').read()

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : Re: [Bug 1048040] Re: [7.0 trunk] Exception loading data into new DB - partner image

2012/11/5 Anil Saraswathy <email address hidden>:
> The problem is with the file open call. Since these are binary files, you need to specify read-binary mode as follows:
> image = open(openerp.modules.get_module_resource('base', 'static/src/img', 'company_image.png'), 'rb').read()

Please do not use this idiom, which relies on the garbage collector to
close the file. Use the "with" keyword:

with open(openerp.modules.get_module_resource('base',
'static/src/img', 'company_image.png'), 'rb') as fobj;
    image = fobj.read()

Thanks.

--
Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 92

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
http://www.camptocamp.com

Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :

Hello tozm,

I have tested your issue in windows 7 with latest trunk of OpenERP 6.2dev-20121106-000101 with nightly. But I didn't face any traceback during installation. So, would you please try with latest? And notify us if you face any problem.

Thanks For reporting ..!!!

Changed in openobject-server:
status: New → Invalid
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Reproduced today on dev environment on Windows (might not happen with all-in-one package, to be verified)

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Medium
status: Invalid → Confirmed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

It should be fixed at server revision 4540 (rev-id: <email address hidden>)
Thanks for reporting!

Changed in openobject-server:
milestone: none → 7.0
status: Confirmed → Fix Released
Revision history for this message
Muzammil (muzammils-c) wrote :

Facing same issue after fresh installation of openerp 7 latest release? All modules installation create this error (tried several modules and none works.

OS : WIndows 8
openerp version: OpenERP 7.0-20140313-003151
Faced during: Installing modules

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.