odooopenerp-7traceback

assign task to multiple users in odoo


in odoo (fromerly openERP) i want to customize Project management module.

currently a task can be assigned to a single user. model code is:

class task(osv.osv):
    _name = "project.task"
    _description = "Task"

    'user_id': fields.many2one('res.users', 'Assigned to', select=True, track_visibility='onchange'),

Now want to assign a task to multiple users. and i have modified user_id field like this:

'user_id': fields.many2many('res.users', 'Assigned to', select=True, track_visibility='onchange'),

but it shows following traceback:

Traceback (most recent call last):
  File "/home/hardik/odoo/odoo/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/hardik/odoo/odoo/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/home/hardik/odoo/odoo/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/hardik/odoo/odoo/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/hardik/odoo/odoo/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/home/hardik/odoo/odoo/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/home/hardik/odoo/odoo/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/home/hardik/odoo/odoo/addons/web/controllers/main.py", line 884, in search_read
    return self.do_search_read(model, fields, offset, limit, domain, sort)
  File "/home/hardik/odoo/odoo/addons/web/controllers/main.py", line 905, in do_search_read
    request.context)
  File "/home/hardik/odoo/odoo/openerp/http.py", line 908, in proxy
    result = meth(cr, request.uid, *args, **kw)
  File "/home/hardik/odoo/odoo/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/hardik/odoo/odoo/openerp/models.py", line 5146, in search_read
    result = self.read(cr, uid, record_ids, fields, context=read_ctx)
  File "/home/hardik/odoo/odoo/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/hardik/odoo/odoo/openerp/models.py", line 3141, in read
    result = BaseModel.read(records, fields, load=load)
  File "/home/hardik/odoo/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/hardik/odoo/odoo/openerp/models.py", line 3176, in read
    self._read_from_database(stored, inherited)
  File "/home/hardik/odoo/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/home/hardik/odoo/odoo/openerp/models.py", line 3354, in _read_from_database
    res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
  File "/home/hardik/odoo/odoo/openerp/osv/fields.py", line 1012, in get
    cr.execute(query, [tuple(ids),] + where_params)
  File "/home/hardik/odoo/odoo/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/home/hardik/odoo/odoo/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
ProgrammingError: syntax error at or near "to"
LINE 1: SELECT Assigned to.res_users_id, Assigned to.project_task_id...
                        ^

please guide me how to deal with this. thanks in advance


Solution

  • When we create many2many type field, than we must to give a name of relation table where in that table record will store. In below example 'task_user_rel' is a relational table.

    You may try this code:

    'user_ids': fields.many2many('res.users', 'task_user_rel', 'user_id', 'id', 'Assigned to', select=True, track_visibility='onchange'),
    

    Now add new user_ids field in xml side and hide/invisible a exists user_id field.