Community: Framework mailing list archives

expert-framework@mail.odoo.com

Re: v8.0 - Cannot create computed field - Field is accessed before being computed.

by
Axel
- 10/16/2014 05:50:40
Hi,

Typically you would get this error if your compute method dooesn't set the corresponding field value, the common mistake being trying to return the value.

So make sure your _data_get() does this:

def _data_get(self):
  # compute value
  self.datas = value

And not this :

def _data_get(self):
  # compute value
  return value

On Wed, Oct 15, 2014 at 1:37 AM, Maxim Litnitskiy <litnimaxster@gmail.com> wrote:
Hi dear Experts.
In old api we had no problems creating function fields like the following (from ir_attachment.py):

...
'datas': fields.function(_data_get, fnct_inv=_data_set, string='File Content', type="binary", nodrop=True),  
...
 
In new api the following code is working on read / update, but gives error "Field is accessed..."  on create:

...
datas = fields.Binary(compute='_data_get', inverse='_data_set', string=_('File content'), required=True)
...

Is it supposed to work or not?
Thanks.


P.S. May be some concept has changed. I can imagine that in form edit mode I use real Binary field (not computed) and mirror it via @api.depend on computed field? 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe