That is quite unfortunately caused by a bug in certain Python 2.6 versions on RedHat/CentOS. OpenERP uses standard Python 2.6 features that seem to work on all other Python 2.6 platforms.
As discussed on Launchpad answer #185679 and in the forum [1], it seems that on affected Python 2.6 versions it is impossible to nest more than 4 "if" filters in a list comprehension expression.
The ir.model class uses a list comprehension expression with 5 nested ifs:
def _get_fields_type(self, cr, uid, context=None):
return sorted([(k,k) for k,v in fields.__dict__.iteritems() if type(v) == types.TypeType if issubclass(v, fields._column) if v != fields._column if not v._deprecated if not issubclass(v, fields.function)])
We could implement a workaround for CentOS in this specific case, but it does not guarantee that we will not see other similar (but less obvious) cases of this same problem, because it breaks our fundamental hypothesis of "cross-platformness" of Python!
My google skills did not reveal any obvious bug report on Fedora/CentOS/RedHat, so it would perhaps be a good idea to report this upstream and get it fixed where it should be.
One way to rewrite the above code without so many nested `if`s is to simply replace them with `and`s:
def _get_fields_type(self, cr, uid, context=None):
return sorted([(k,k) for k,v in fields.__dict__.iteritems() if type(v) == types.TypeType and \ issubclass(v, fields._column) and \ v != fields._column and \ not v._deprecated and \ not issubclass(v, fields.function)])
Hello,
That is quite unfortunately caused by a bug in certain Python 2.6 versions on RedHat/CentOS. OpenERP uses standard Python 2.6 features that seem to work on all other Python 2.6 platforms.
As discussed on Launchpad answer #185679 and in the forum [1], it seems that on affected Python 2.6 versions it is impossible to nest more than 4 "if" filters in a list comprehension expression.
The ir.model class uses a list comprehension expression with 5 nested ifs:
def _get_fields_ type(self, cr, uid, context=None): __dict_ _.iteritems( )
if type(v) == types.TypeType
if issubclass(v, fields._column)
if v != fields._column
if not v._deprecated
if not issubclass(v, fields.function)])
return sorted([(k,k) for k,v in fields.
We could implement a workaround for CentOS in this specific case, but it does not guarantee that we will not see other similar (but less obvious) cases of this same problem, because it breaks our fundamental hypothesis of "cross- platformness" of Python! CentOS/ RedHat, so it would perhaps be a good idea to report this upstream and get it fixed where it should be.
My google skills did not reveal any obvious bug report on Fedora/
One way to rewrite the above code without so many nested `if`s is to simply replace them with `and`s:
def _get_fields_ type(self, cr, uid, context=None): __dict_ _.iteritems( )
if type(v) == types.TypeType and \
issubclass( v, fields._column) and \
v != fields._column and \
not v._deprecated and \
not issubclass(v, fields.function)])
return sorted([(k,k) for k,v in fields.
[1] http:// www.openerp. com/forum/ topic30304. html