[v6rc2] orm read() fails when no fields-list passed, on objects that override parent columns
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Fix Released
|
Medium
|
OpenERP's Framework R&D |
Bug Description
Hello,
The "project" module has been modified since rc1, among other things, the field "parent_id" is now a "project.project" and doing a XMLRPC read on a project having this field set now leads to a server error, as described below.
Steps to reproduce:
* install v6rc2 with the project module
* create two projects "foo" (id 1) and "bar" (id 2) having "foo" as parent
* execute(1,"read") => succeeds
* execute(
* execute(2,"read") => FAILS with the following error:
---
[2011-01-10 14:03:12,035][main] ERROR:db.
LINE 1: ...d FROM "project_project" WHERE project_project.id IN ((1, E'...
, in query SELECT project_
[2011-01-10 14:03:12,036][main] ERROR:web-
Traceback (most recent call last):
File "/home/
return f(self, dbname, *args, **kwargs)
File "/home/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/
result = self._read_flat(cr, user, select, fields, context, load,indent+" ")
File "/home/
res2 = self._columns[
File "/home/
records = dict(obj.
File "/home/
[self.
File "/home/
result = self._read_flat(cr, user, select, fields, context, load,indent+" ")
File "/home/
cr.
File "/home/
return f(self, *args, **kwargs)
File "/home/
res = self._obj.
ProgrammingError: arguments of row IN must all be row expressions
LINE 1: ...d FROM "project_project" WHERE project_project.id IN ((1, E'...
[2011-01-10 14:03:12,039][main] DEBUG_RPC:
[2011-01-10 14:03:12,040][main] DEBUG_RPC:
---
As it occurs in sql_db.py, it is not specific to the project module as far as I understand the issue.
Adding some trace in orm.py:_flat_read() show the query to be:
SELECT project_
with args= ((1, u'foo'),), where a list of ints is expected.
Somehow there's no impact on the user interface (so far), I guess the client doesn't use a full read() but read each field separately.
I think I found the issue: list(set( fields) )
In orm.py:read(), if no "fields" argument is passed, the set of all fields (local and inherited) is computed. This lead to a problem when the same field has been redefined: in that case, "fields" contains several entries with the same name which can't work with the read()/_flat_read() logic [which reuse the same structure completed with the fields values if I understand correctly].
Anyway, simply adding [line 2916] something like:
---
fields=
---
to eliminate duplicates solves this problem.