Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get image in product module in openerp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 195
    Comment on it

    To get small image in product module first inherit the product.product object in product module and add one fields like image_small and write the fucntion _get_image in your own module in openerp.
    for example you can use the below fucntion in .py file,

    def _get_image(self, cr, uid, ids, prop, unknow_none, context=None):
            result = {}
            for obj in self.browse(cr, uid, ids, context=context):
                if not obj.product_image:
                    result[obj.id] = False
                    continue
    
                image_stream = io.BytesIO(obj.product_image.decode('base64'))
                img = Image.open(image_stream)
                img.thumbnail((120, 100), Image.ANTIALIAS)
                img_stream = StringIO.StringIO()
                img.save(img_stream, "JPEG")
                result[obj.id] = img_stream.getvalue().encode('base64')
            return result
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: