# -*- coding: utf-8 -*-
from odoo import models, fields, api
class TodoTask(models.Model):
_name = 'todo.task'
_description = 'To-do Task'
name = fields.Char('Description', required=True)
is_done = fields.Boolean('Done?')
active = fields.Boolean('Active', default=True)
@api.multi
def do_toggle_done(self):
for task in self:
task.is_done = not task.is_done
return True
@api.model
def do_clear_done(self):
dones = self.search([('is_done', '=', True)])
dones.write({'active': False})
return True
and getting Error is
Traceback (most recent call last): File "/home/odoo10/odoo-dev/odoo/odoo/http.py", line 638, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/odoo10/odoo-dev/odoo/odoo/http.py", line 675, in dispatch result = self._call_function(**self.params) File "/home/odoo10/odoo-dev/odoo/odoo/http.py", line 331, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/odoo10/odoo-dev/odoo/odoo/service/model.py", line 119, in wrapper return f(dbname, *args, **kwargs) File "/home/odoo10/odoo-dev/odoo/odoo/http.py", line 324, in checked_call result = self.endpoint(*a, **kw) File "/home/odoo10/odoo-dev/odoo/odoo/http.py", line 933, in __call__ return self.method(*args, **kw) File "/home/odoo10/odoo-dev/odoo/odoo/http.py", line 504, in response_wrap response = f(*args, **kw) File "/home/odoo10/odoo-dev/odoo/addons/web/controllers/main.py", line 882, in call_button action = self._call_kw(model, method, args, {}) File "/home/odoo10/odoo-dev/odoo/addons/web/controllers/main.py", line 870, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/odoo10/odoo-dev/odoo/odoo/api.py", line 679, in call_kw return call_kw_model(method, model, args, kwargs) File "/home/odoo10/odoo-dev/odoo/odoo/api.py", line 662, in call_kw_model recs = self.with_context(context or {}) File "/home/odoo10/odoo-dev/odoo/odoo/models.py", line 4865, in with_context context = dict(args[0] if args else self._context, **kwargs) TypeError: cannot convert dictionary update sequence element #0 to a sequence
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
If that function is new you should use api.multi
Thanks Esther Martin it's working...
but can you explain why it's not working with @api.model
why @api.model not working for this action even in code there is no loop.
why new function require @api.multi ??
You can found everything about api here: https://www.odoo.com/documentation/8.0/reference/orm.html
Anyways, for new functions, is always used multi.
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
2
abr 24
|
1536 | ||
|
0
mar 19
|
2980 | ||
|
1
oct 18
|
2739 | ||
|
0
mar 17
|
3088 | ||
|
2
jul 24
|
1318 |
when is this function called ? 'do_clear_done'
yes @Hilar this happen when i call 'do_clear_done'