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.


How can I migrate this code to Odoo?? (_get_image function)

on 3/9/15, 8:20 AM 958 views

How can I migrate this code to the versión 8?? How can I get the "ids" variable?   

def _get_image(self, cr, uid, ids, context=None):
        result = dict.fromkeys(ids, False)
        for obj in self.browse(cr, uid, ids, context=context):
            result[obj.id] = tools.image_get_resized_images(obj.image, avoid_resize_medium=True)
        return result
    def _set_image(self, cr, uid, id, name, value, context=None):
        return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)    
    _columns = {
        'image': fields.binary("Image", help="This field holds the image used as image for the category, 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),
            help="Medium-sized image of the category. It is automatically "\
                 "resized as a 128x128px image, with aspect ratio preserved. "\
                 "Use this field in form views or some kanban views."),





Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.


Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 


We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :


  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 3/10/15, 6:18 AM

Hi Chesucr,

You can migrate your code as like below. You just need to chage your functions like below and you code will be migrate into V8.

    def _get_image(self, name, args):
        return dict((p.id, tools.image_get_resized_images(p.image)) for p in self)

    def _set_image(self, name, value, args):
        return self.write({'image': tools.image_resize_image_big(value)})

I hope you will get your result. 

Note : Please refer python file from odoo=>openerp=>addons=>base=>res=>res_partner.py in this file looking on the class res_partner.

mmm I think you copied the code from here https://www.odoo.com/es_ES/forum/help-1/question/avatar-image-in-new-api-69525 but that doesn't work. Thanks anyway. Moreover with @api.one and @api.multi you only need 'self' as argument. With the function _set_image I get this error: RuntimeError: maximum recursion depth exceeded. I will go on with my research

on 3/10/15, 8:03 AM

As I have write down on the note. I have seen this in that file. I have not copied from https://www.odoo.com/es_ES/forum/help-1/question/avatar-image-in-new-api-69525.

Emipro Technologies Pvt. Ltd.
on 3/10/15, 8:40 AM

OK thanks, I owe you one ;) I tried the functions with this field and it worked: image = fields.Binary("Second product image", compute="_get_image", multi="_get_image", inverse="_set_image")

on 3/13/15, 5:56 AM
On 8/22/16, 7:49 AM

what is now the complete answer ( code) ?



| 5 3 8
Pondicherry, India
On 3/9/15, 9:39 AM


please refer this link for your way to do migration:


I was talking about code migration instead database migration, thanks anyway

on 3/9/15, 11:20 AM

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: 3/9/15, 8:20 AM
Seen: 958 times
Last updated: 8/22/16, 7:49 AM