Comment 0 for bug 976909

Revision history for this message
GEM (nimp3) wrote :

Hi,
this bug is for web client 6.0 (perhaps for 5.0 too)
I saw some bugs with this message "object of type 'int' has no len()" , but seems to be not this I had, I explain :

I have 2 classes.
For each class, I have 2 fields type many2many (then, there is a total of 4 m2m for the 2 classes)
I want to update values of the first class with values of the second class (there is a common key between them naturally), the first field of the class one is updated with the first field of the class two, the second field of the class one is updated with the second field of the class two, using the common key of the 2 classes.
to update the first class with the second I use an on_change method, inwhich I return the result with return {'value': res}
This return works with client gtk, but with client web I have this error when I do "save" for the form :

   84 if (self.ids or self.id) and self.count == 0:
   85 if self.ids and len(self.ids) < self.limit:
   86 self.count = len(self.ids)
   87 else:
self = Screen, self.ids = 11, builtin len = <built-in function len>, self.limit = 50

<type 'exceptions.TypeError'>: object of type 'int' has no len()
      args = ("object of type 'int' has no len()",)
      message = "object of type 'int' has no len()"

If I try to return just one field (the one or the second), it works in client web too.

I find a patch to solve this bug by changing in client web (in fact I do a list of integer which can be read by method len() :

in openerp-web/addons/openerp/widgets/screen.py line 85 :
- if self.ids and len(self.ids) < self.limit:
+if isinstance(self.ids, (int, long)):
+ self.ids = [self.ids]
+if self.ids and len(self.ids) < self.limit:

Bye