fields.function stored with multi argument and mixed integer/manyone types
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Fix Committed
|
Low
|
OpenERP Publisher's Warranty Team |
Bug Description
This is quite a tricky bug that requires 2 fields.function stored in database, linked with a 'multi' argument and of two different types: integer and many2one. Something like that:
_columns = {
'm2o_field_id': fields.
'integer_field': fields.
}
Lets say, _store_
in orm.py, line 3824, you have:
todo = {}
keys = []
for f in fields:
if self._columns[
for key in keys:
val = todo[key]
if key:
# uid == 1 for accessing objects having rules defined on store fields
so val will contain either ['m2o_field_id', 'integer_field'] or ['integer_field', 'm2o_field_id'] depending on the order they are called
and the fields.get function will be called with val[0] which is either an integer field or a many2one field.
Now if you go to the get function of fields.function, you have this type of code:
fields.py, line 817
if self._type == "many2one" :
# Filtering only integer/long values if passed
res_ids = [x for x in res.values() if x and isinstance(x, (int,long))]
if res_ids:
for r in res.keys():
if self._type == "integer":
for r in res.keys():
# Converting value into string so that it does not affect XML-RPC Limits
if isinstance(
Either way, the function _get_infos will return something like that:
{my_id:{
'integer_field': 200,
'm2o_field_id': 42,
}}
but the result in _store_set_values will have either (depending on the order):
- if val[0] is a many2one:
result ={my_id:{
'integer_field': 200,
'm2o_field_id': 42,
}} (no_action)
or
- if val[0] is an integer:
result ={my_id:{
'integer_field': '200',
'm2o_field_id': '42',
}} (integer field transforms into string)
And in _store_set_values, you have:
in orm.py, line 3834
for id, value in result.items():
#some code
for v in value:
if v not in val:
if self._columns[
try:
except:
So we will store either:
{
'integer_field': 200,
'm2o_field_id': 42,
} => OK
or
{
'integer_field': '200',
'm2o_field_id': '4', #instead of 42
} => KO
depending on the order...
server 6.0, revno 3626
Related branches
- Naresh(OpenERP): Pending requested
- Olivier Dony (Odoo): Pending requested
-
Diff: 78 lines (+35/-27)1 file modifiedbin/osv/fields.py (+35/-27)
description: | updated |
Changed in openobject-server: | |
assignee: | nobody → OpenERP Publisher's Warranty Team (openerp-opw) |
tags: | added: maintenance |
Changed in openobject-server: | |
status: | In Progress → Fix Committed |
When mixing different types of fields.function with the same `multi` value, the post-processing steps of one of the fields types may be inadvertently applied to the values of the other fields. This is a rare occurrence, as `multi` is mostly used to combine function.fields of the same type. function. get() was refactored and corrected for 6.1.
This issue does not exist in 6.1+, as fields.