in my model.py, I have:
totFee = fields.Float(compute='_compute_totFee')
@api.depends('field1','field2')
def _compute_totFee(self):
for rec in self:
self.totFee = 44
I get an error message:
ERROR crc openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
File "/opt/odoo/openerp/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/openerp/http.py", line 680, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/openerp/http.py", line 316, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/openerp/http.py", line 309, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/openerp/http.py", line 959, in __call__
return self.method(*args, **kw)
File "/opt/odoo/openerp/http.py", line 509, in response_wrap
response = f(*args, **kw)
File "/opt/enterprise-9/web/controllers/main.py", line 911, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/enterprise-9/web/controllers/main.py", line 903, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/opt/odoo/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 3193, in read
result = BaseModel.read(records, fields, load=load)
File "/opt/odoo/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 3239, in read
values[name] = field.convert_to_read(record[name], use_name_get)
File "/opt/odoo/openerp/models.py", line 5740, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/opt/odoo/openerp/fields.py", line 829, in __get__
self.determine_value(record)
File "/opt/odoo/openerp/fields.py", line 936, in determine_value
self.compute_value(recs)
File "/opt/odoo/openerp/fields.py", line 891, in compute_value
self._compute_value(records)
File "/opt/odoo/openerp/fields.py", line 881, in _compute_value
getattr(records, self.compute)()
AttributeError: 'transactions' object has no attribute '_compute_totFee'
how would I write that function?
TIA
Hi Yves, Is your function above the fields.Float that has the compute field? If the function is under the fields.Float move it above the fields.Float. Regards, Yenthe
check the indentation of method, it should be inside the class