← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 684263] Re: Server ORM bug V5. Error when using function field (type : boolean, store=True)

 

** Tags added: maintenance

** Summary changed:

- Server ORM bug V5. Error when using function field (type : boolean, store=True)
+ [5.0] ORM: Error when using boolean function field (type : boolean, store=True)

** Summary changed:

- [5.0] ORM: Error when using boolean function field (type : boolean, store=True)
+ [5.0] ORM: NULL stored instead of False when using boolean function field (type : boolean, store=True)

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/684263

Title:
  [5.0] ORM: NULL stored instead of False when using boolean function field (type : boolean, store=True)

Status in OpenObject Server:
  Confirmed

Bug description:
  Hi
We are working on fleet_maintenance. (not the version in extra-addons but this version : https://code.launchpad.net/~akretion-team/openobject-addons/fleet_maintenance_anevia)
We use function.fields with the type boolean and the option store=True.

When we check in the database, we don't see any value 'False' in the column of our field. Only the values Null or True are present. After some code inspection, we found where is the bug.

Indeed, on a standard field boolean, the value is force to "True" or "False". On a function field, the function called to set the field to "False" or "True" returns a wrong result : it returns the value "True" or "None".

To see what is wrong, add some print in the orm.py line 3003 :


 result = self._columns[f].get(cr, self, ids, f, uid, context=context)
                    for id,value in result.items():
+                        print 'value', value
+                        print 'f', f
+                        print 'symbol type', self._columns[f]._type
+                        print 'self._columns[f]._symbol_set[1](True)',self._columns[f]._symbol_set[1](True)
+                        print 'self._columns[f]._symbol_set[1](False)',self._columns[f]._symbol_set[1](False)
                        if self._columns[f]._type in ('many2one', 'one2one'):
                            try:
                                value = value[0]
                            except:
                                pass

The result of the print are :
value False
f is_expired
symbol type boolean
self._columns[f]._symbol_set[1](True) True
self._columns[f]._symbol_set[1](False) None

In this case (only for a function field with the type boolean, not for a pure boolean field) the method _symbol_set[1](False) returns "None" and not "False".

I try to modify the _symbol_set method in field.py
class boolean(_column):
    _type = 'boolean'
    _symbol_c = '%s'
    _symbol_f = lambda x: x and 'True' or 'False'
    _symbol_set = (_symbol_c, _symbol_f)

with incorrect value in order to crash openerp, but it doesn't use this code for a function fields. Here is the problem : it should execute this code as it's a boolean field.

Hope reporting this bug will help you.

For people which are affected by this bug you can use this patch.





References