Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
8548 Visualizzazioni

I want to use an avatar image in a class, using the new odoo api, but i'm having some errors:

    image = fields.Binary("Image", default='_get_default_image',
                         help="This field holds the image used as avatar for this student, limited to 1024x1024px")
    image_medium = fields.Binary(string="Medium-sized image", store=True, compute="_get_image",   inverse='_set_image',
                                help="Medium-sized image of this contact. It is automatically " \
                                     "resized as a 128x128px image, with aspect ratio preserved. " \
                                     "Use this field in form views or some kanban views.")

these are the functions:

    @api.multi
    def _get_default_image(self):
        image_path = openerp.modules.get_module_resource('af', 'static/src/img', 'default_image.png')
        return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
    
    @api.multi
    @api.depends('image')
    def _get_image(self):
        return dict((s.id, tools.image_get_resized_images(s.image)) for s in self)
    
    @api.one
    def _set_image(self, name, value, args):
        return self.write({'image': tools.image_resize_image_big(value)})

What i'm doing wrong? What i have to change or add?

Any help, thanks ins advanced.

Regards

Avatar
Abbandona
Autore

Any help?

You may want to edit your post and indicate what the errors are.

Risposta migliore

The solution here ;)

https://www.odoo.com/forum/help-1/question/how-can-i-migrate-this-code-to-odoo-get-image-function-81465

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
mag 20
7837
3
dic 23
19907
6
mar 16
25975
2
gen 20
15761
0
gen 17
11291