Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to resize image in odoo new api (Odoo9)?

By
Sebin Siby
on 7/26/16, 7:15 AM 279 views

Hi,


I want to resize the uploaded image in my application and save it to the database, how to achieve this in odoo9?

0
kirubanidhi
On 7/26/16, 9:40 AM

Hai,

In odoo 9 we Specify these header file

from openerp.tools import DEFAULT_SERVER_DATE_FORMAT,image_colorize, image_resize_image_big

Py file:

stud_image = fields.Binary('Photo', default=lambda self:\

self._get_default_image())

@api.model

def _get_default_image(self, colorize=False):

image = image_colorize(open(openerp.modules.get_module_resource('base',

'static/src/img', 'avatar.png')).read())

return image_resize_image_big(image.encode('base64'))

0
OpenGest.Solutions
On 7/26/16, 1:31 PM

You can maybe follow the res_partner code:

http://gitlab.opengest.solutions/opengest/odoo/blob/9.0/openerp/addons/base/res/res_partner.py#L257

image_medium = openerp.fields.Binary("Medium-sized image", attachment=True,

help="Medium-sized image of this contact. It is automatically "\

"resized as a 128x128px image, with aspect ratio preserved. "\

"Use this field in form views or some kanban views.")

http://gitlab.opengest.solutions/opengest/odoo/blob/9.0/openerp/addons/base/res/res_partner.py#L290

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/26/16, 7:15 AM
Seen: 279 times
Last updated: 9/6/16, 9:48 AM