← Back to team overview

openerp-india team mailing list archive

Re: [Bug 1048040] Re: [7.0 trunk] Exception loading data into new DB - partner image

 

2012/11/5 Anil Saraswathy <anilgs@xxxxxxxxx>:
> 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

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1048040

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

Status in OpenERP Server:
  New

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">info@xxxxxxxxxxxxxxx</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 -

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1048040/+subscriptions


References