[trunk] Sparse field : AttributeError: 'sparse' object has no attribute 'relation'

Bug #912203 reported by Guewen Baconnier @ Camptocamp
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
High
OpenERP's Framework R&D

Bug Description

Hello,

It concerns the sparse field recently introduced in the trunk version.
I made a merge proposal here : https://code.launchpad.net/~c2c/openobject-server/trunk-server-sparse-fix-gbr/+merge/87595

An error may occur when multi sparse field are stored in a serialized field and at least one is a m2o, m2m or o2m.
The current code call self.relation, but as we loop on field_names, it should be obj._columns[field_name].relation

Traceback (most recent call last):
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/osv.py", line 120, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/osv.py", line 172, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/osv.py", line 163, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/orm.py", line 3372, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/orm.py", line 3451, in _read_flat
    res2 = self.pool.get(table).read(cr, user, [x[col] for x in res], cols, context, load)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/orm.py", line 3372, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/orm.py", line 3483, in _read_flat
    res2 = self._columns[val[0]].get(cr, self, ids, val, user, context=context, values=res)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/fields.py", line 1048, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/home/gbaconnier/code/camptocamp/alpha/src/server/openerp/osv/fields.py", line 1280, in _fnct_read
    relation_obj = obj.pool.get(self.relation)
AttributeError: 'sparse' object has no attribute 'relation'

Related branches

Revision history for this message
Kyle Waid (midwest) wrote :

I confirm this error

Traceback (most recent call last):
  File "/usr/local/openerp/openerp-server/openerp/osv/osv.py", line 120, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/local/openerp/openerp-server/openerp/osv/osv.py", line 175, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/local/openerp/openerp-server/openerp/osv/osv.py", line 163, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/local/openerp/openerp-server/openerp/osv/orm.py", line 3372, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/usr/local/openerp/openerp-server/openerp/osv/orm.py", line 3451, in _read_flat
    res2 = self.pool.get(table).read(cr, user, [x[col] for x in res], cols, context, load)
  File "/usr/local/openerp/openerp-server/openerp/osv/orm.py", line 3372, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/usr/local/openerp/openerp-server/openerp/osv/orm.py", line 3483, in _read_flat
    res2 = self._columns[val[0]].get(cr, self, ids, val, user, context=context, values=res)
  File "/usr/local/openerp/openerp-server/openerp/osv/fields.py", line 1061, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/usr/local/openerp/openerp-server/openerp/osv/fields.py", line 1309, in _fnct_read
    relation_obj = obj.pool.get(self.relation)
AttributeError: 'sparse' object has no attribute 'relation'

Revision history for this message
Kyle Waid (midwest) wrote :

I tried your patch and it had no effect. Thanks

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello Kyle, I'm pretty sure that my patch works.
But what's your 6.1 server revno because your line numbers are not the same as mine.

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Guewen Baconnier,

I have not face any trace back like yours so would
 you please elaborate more regarding this issue.
Please provide proper steps for reproducing this issue.

Thanks and waiting for reply!

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello,

That's not so trivial because you need a serialized field and sparse fields linked to this serialized field.
At least one must be a many2one / m2m / o2m and one must not be a relation (in order not to have a "relation" attribute).

Here is a screencast of what you can do to issue this bug : http://www.screencast.com/t/VE24jk2WPatk

Thanks

Changed in openobject-server:
status: Incomplete → New
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hi,

From your point of view, this is considered as low, I understand well, because this sparse fields are not used in OpenERP actually.
But this is now a feature of the framework and this bug totally prevents an usage of these fields. We use it as instance in magentoerpconnect.

I provided the fix, a branch and shown you how to reproduce the issue with a screencast.
If I'm not wrong, this is a very straightforward and little error and fix.
Moreover, if my fix were wrong (but I don't think so), nobody except the Magentoerpconnect modules editors (so mainly Akretion and us on trunk) would be impacted, but anyway it does not work at the moment...

So if someone can apply my patch, I would be grateful.

Thanks & have a nice day
Guewen

Revision history for this message
Kyle Waid (midwest) wrote :

Hi,

I checked again and I made a mistake. Your patch fixes the issue. I really hope we can get this fix merged soon. It is a relatively small patch so it should not require too much review.

@OpenERP
Please merge the fix into the trunk. Thank you.

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

I confirm this patch work.
Thank for merging it ;)

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Dear OpenERP's team,

I confirm the patch works. Please, can you merge this ASAP. We made all the work to explain the bug, we made a clean merge proposal and this really block us.

As Guewen said, it is low for you because not really use in the default modules, but this is a serious bug for the framework. For that reason, I put a higher priority. We cannot release 6.1 with that kind of bug.

Thank you very much for your consideration,

Regards,

Joël

Changed in openobject-server:
importance: Low → High
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Guewen's fix has landed in trunk at revision 4054 rev-id: <email address hidden>

Thanks!

Changed in openobject-server:
milestone: none → 6.1
status: Confirmed → Fix Released
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.