String index out of range opening some views (like H.R. Working Hours)

Bug #562881 reported by Borja López Soilán (NeoPolus)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KDE OpenObject Client
Invalid
Undecided
Unassigned

Bug Description

Trying to open some views, like the Working Hours in the human resources module, will cause Koo to halt while displaying again and again (about one each second) this traceback:

---
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/KooModel.py", line 333, in data
    value = self.value( index.row(), index.column(), index.internalPointer() )
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/KooModel.py", line 666, in value
    return model.value( field )
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/Record.py", line 112, in value
    self.group.ensureModelLoaded( self )
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/Group.py", line 634, in ensureModelLoaded
    self.recordById(id).set(v, signal=False)
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/Record.py", line 381, in set
    self.updateAttributes()
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/Record.py", line 177, in updateAttributes
    if condition[i][2] and isinstance(condition[i][2], list):
IndexError: string index out of range
---

Revision history for this message
Borja López Soilán (NeoPolus) (borjals) wrote :

Ok, I debuged it a bit and found that the root problem was on the view (had invalid attrs), but the Web and GTK clients just ignore this invalid attrs, while Koo halts:

This is the code where the IndexError is raised:
---
   for attribute, condition in attributeChanges.items():
    for i in range(0, len(condition)):
     if condition[i][2] and isinstance(condition[i][2], list):
---

The problematic field is defined like this:
      <field attrs="{'invisible':'True'}" domain="[('type','=','service')]" name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" required="1"/>

If you debug, you can see this:

ipdb> pp fieldName
'product_id'
ipdb> pp attributes
u"{'invisible':'True'}"
ipdb> pp attributeChanges
{'invisible': 'True'}
ipdb> pp attributeChanges.items()
[('invisible', 'True')]
ipdb> pp condition[0] # Condition elements aren't list or tuples! so we can't do condition[i][2]!
'T'
ipdb> pp condition[0][2] # This won't work: condition[0] is a single-char string
*** IndexError: IndexError('string index out of range',)

So, the problem is that the attrs was invalid: "attrs: Python map defining dynamic conditions on these attributes: readonly, invisible, required based on search tuples on other field values"

That is, the root problem, it's not a Koo problem, but a problem in the view. Though Koo is not handling it like the other clients (ignoring it), but it instead prints a stacktrace for each record (that hungs the client for several minutes).

Changed in openobject-client-kde:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.