- def onchange_photo(self, cr, uid, ids, value, context=None):
- if not value:
- return {'value': {'photo_big': value, 'photo': value} }
- return {'value': {'photo_big': self._photo_resize(cr, uid, value, 540, 450, context=context), 'photo': self._photo_resize(cr, uid, value, context=context)} }
-
- def _set_photo(self, cr, uid, id, name, value, args, context=None):
- if not value:
- vals = {'photo_big': value}
- else:
- vals = {'photo_big': self._photo_resize(cr, uid, value, 540, 450, context=context)}
- return self.write(cr, uid, [id], vals, context=context)
-
- def _photo_resize(self, cr, uid, photo, heigth=180, width=150, context=None):
- image_stream = io.BytesIO(photo.decode('base64'))
- img = Image.open(image_stream)
- img.thumbnail((heigth, width), Image.ANTIALIAS)
- img_stream = StringIO.StringIO()
- img.save(img_stream, "JPEG")
- return img_stream.getvalue().encode('base64')
-
- def _get_photo(self, cr, uid, ids, name, args, context=None):