Odoo Help


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.


Set Image Size in a model

Jérémy Hermand
on 1/27/15, 11:59 AM 788 views


I created a module that should contain 4 images and I will like these images have a resolution of 700X255px (it can be crop) but I do not know how.

I looked in the product class, but I do not understand how it's make:
    'image': fields.binary("Image",
      help="This field holds the image used as image for the product, limited to 1024x1024px."),
  'image_medium': fields.function(_get_image, fnct_inv=_set_image,
      string="Medium-sized image", type="binary", multi="_get_image",
          'product.template': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),

Nowhere in code, I see that where is specify the size

Could you help me, here is my model:
 class Room(models.Model):
    _name = my.room'

    visual1_id = fields.Many2one('ir.attachment', ondelete='cascade', string="Image 1")
    visual2_id = fields.Many2one('ir.attachment', ondelete='cascade', string="Image 2")
    visual3_id = fields.Many2one('ir.attachment', ondelete='cascade', string="Image 3")
    visual4_id = fields.Many2one('ir.attachment', ondelete='cascade', string="Image 4")

and this is my view
    <field name="visual1_id" widget="image"/>
    <field name="visual2_id" widget="image"/>
    <field name="visual3_id" widget="image"/>
    <field name="visual4_id" 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)


Asked: 1/27/15, 11:59 AM
Seen: 788 times
Last updated: 3/16/15, 8:10 AM