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.

3
Narendran
On 7/5/16, 9:13 AM

I got this Code from Base code itself, anyway this will be helpful for those who searching for default image in odoo 9.

In Header, 

from openerp.tools import openerp,image_colorize, image_resize_image_big


In Py,

photo = fields.Binary(string="Image to upload", 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'))


In Xml, should specify widget="image" for showing image in Form.

<field name="photo" widget="image" />





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/5/16, 8:33 AM
Seen: 938 times
Last updated: 7/5/16, 9:13 AM