Traceback (most recent call last): File "/home/khan/odoo-16.0/odoo/api.py", line 984, in get cache_value = field_cache[record._ids[0]] KeyError: During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/khan/odoo-16.0/odoo/fields.py", line 1160, in __get__ value = env.cache.get(record, self) File "/home/khan/odoo-16.0/odoo/api.py", line 991, in get raise CacheMiss(record, field) odoo.exceptions.CacheMiss: 'practice.module(,).total_books' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/khan/odoo-16.0/odoo/api.py", line 984, in get cache_value = field_cache[record._ids[0]] KeyError: During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/khan/odoo-16.0/odoo/fields.py", line 1213, in __get__ value = env.cache.get(record, self) File "/home/khan/odoo-16.0/odoo/api.py", line 991, in get raise CacheMiss(record, field) odoo.exceptions.CacheMiss: 'practice.module(,).total_books' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/khan/odoo-16.0/odoo/http.py", line 1584, in _serve_db return service_model.retrying(self._serve_ir_http, self.env) File "/home/khan/odoo-16.0/odoo/service/model.py", line 133, in retrying result = func() File "/home/khan/odoo-16.0/odoo/http.py", line 1611, in _serve_ir_http response = self.dispatcher.dispatch(rule.endpoint, args) File "/home/khan/odoo-16.0/odoo/http.py", line 1815, in dispatch result = self.request.registry['ir.http']._dispatch(endpoint) File "/home/khan/odoo-16.0/odoo/addons/base/models/ir_http.py", line 154, in _dispatch result = endpoint(**request.params) File "/home/khan/odoo-16.0/odoo/http.py", line 697, in route_wrapper result = endpoint(self, *args, **params_ok) File "/home/khan/odoo-16.0/addons/web/controllers/dataset.py", line 42, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/khan/odoo-16.0/addons/web/controllers/dataset.py", line 33, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/khan/odoo-16.0/odoo/api.py", line 461, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/home/khan/odoo-16.0/odoo/api.py", line 448, in _call_kw_multi result = method(recs, *args, **kwargs) File "/home/khan/odoo-16.0/odoo/models.py", line 6524, in onchange snapshot1 = Snapshot(record, nametree) File "/home/khan/odoo-16.0/odoo/models.py", line 6284, in __init__ self.fetch(name) File "/home/khan/odoo-16.0/odoo/models.py", line 6294, in fetch self[name] = record[name] File "/home/khan/odoo-16.0/odoo/models.py", line 5876, in __getitem__ return self._fields[key].__get__(self, type(self)) File "/home/khan/odoo-16.0/odoo/fields.py", line 1216, in __get__ raise ValueError("Compute method failed to assign %s.%s" % (record, self.name)) ValueError: Compute method failed to assign practice.module(,).total_books The above server error caused the following client error: null
0
1 Trả lời
1
Best Answer
Hi,
Kindly replace you code like this and try,
@api.depends('std_class')
def _class_vise_books(self):
for record in self:
if record.std_class:
if record.std_class == 1:
record.total_books += 4
elif record.std_class == 2:
record.total_books += 5
elif record.std_class == 3:
record.total_books += 6
elif record.std_class == 4:
record.total_books += 6
elif record.std_class == 5:
record.total_books += 7
else:
record.total_books = 0
else:
record.total_books = 0
Thanks
Kindly paste your compute method also for better understanding
Thank you your code is working