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.

0
Janarthanan
On 7/27/16, 6:50 AM

in py 

import 

from openerp.tools import openerp,image_colorize, image_resize_image_big
then add a code 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

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

if in case you need a any other image as default add png image in static/src/img and change the below py code

image = image_colorize(open(openerp.modules.get_module_resource('your_module','static/src/img', 'imagename.png')).read())

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: 5/27/16, 3:49 AM
Seen: 245 times
Last updated: 7/27/16, 6:50 AM