Technical mailing list archives

Re: [8.0] New API: Field x is accessed before being computed.

Pedro M. Baeza
- 09/19/2014 07:19:25
That it's because you are not writing any value in _set_image. Put at least:

   def _set_image(self):
        self.image = False
self.image_medium = False
 self.image_small = False

and it will work.


2014-09-19 12:58 GMT+02:00 Stefan Reisich - GmbH <>:

The following code returns an exception: Field product.template.image_small is accessed before being computed.
I don't understand why. Maybe a bug in the new api?

from openerp import models, fields

class product_template(models.Model):
    _inherit = 'product.template'

    image = fields.Binary('Image', compute='_set_image')
    image_medium = fields.Binary('Medium-sized image', compute='_set_image')
    image_small = fields.Binary('Small-sized image', compute='_set_image')

   def _set_image(self):
        print self

        return ''

Kind regards
Stefan Reisich

Post to: