error when an m2m field is updated by an onchange
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Web Client |
Confirmed
|
Low
|
OpenERP Publisher's Warranty Team |
Bug Description
This bug only appears in the web client, just like #906449.
- Create a view (in our case a wizard) with two fields, the second one being a many2many.
- In an onchange callback on the first field, return something that will update the many2many field (something like { 'value': [1, 2, 3] }).
- When you validate the view or wizard, the server receives [(1, 2, 3)] instead of [1, 2, 3] and fails on a SQL request.
The error shows up in the server log as :
LIGNE 1 : ....id FROM "account_period" WHERE account_period.id IN ((1, 2,...
The SQL request should rather be :
....id FROM "account_period" WHERE account_period.id IN (1, 2,...
==> After hours of digging, we found the error here :
webclient/
if ids and not isinstance(ids, list):
ids = [ids]
It should rather be:
if ids and not isinstance(ids, (list, tuple)):
ids = [ids]
For any reason, the [1, 2, 3] list coming from the server is converted to a tuple, when it reaches the web client. The web client then wraps it in a list and at the end ids = [(1, 2, 3)] instead of [1, 2, 3].
Related branches
- OpenERP Core Team: Pending requested
-
Diff: 12 lines (+1/-1)1 file modifiedaddons/openerp/widgets/listgrid.py (+1/-1)
Changed in openobject-client-web: | |
assignee: | nobody → OpenERP Publisher's Warranty Team (openerp-opw) |
importance: | Undecided → Low |
status: | New → Confirmed |