Hello,

It has been fixed into trunk 
https://code.launchpad.net/~openerp-dev/openobject-server/funciton_field_accessors
 by:
Revision ID: [email protected]
Revno: 3233

Thanks.


** Changed in: openobject-server/trunk
       Status: In Progress => Fix Committed

-- 
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:
  Fields.function : wrong accessors for fields of type 
boolean,integer,integer_big (DB stores null instead of False,0,0 respectively)

Status in OpenObject Server:
  Fix Committed
Status in OpenObject Server 5.0 series:
  Fix Released
Status in OpenObject Server trunk series:
  Fix Committed

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.



_______________________________________________
Mailing list: https://launchpad.net/~c2c-oerpscenario
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~c2c-oerpscenario
More help   : https://help.launchpad.net/ListHelp

Reply via email to