tuple (5) to unlink all values in a many2many field doesn't work

Bug #818189 reported by Christophe Combelles
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

According to the doc : http://doc.openerp.com/v6.0/developer/2_5_Objects_Fields_Methods/methods.html#osv.osv.osv.write
There is a command to unlink all targets of a m2m field :
(5) unlink all (like using (3,ID) for all linked records)

According to openobject-server.6.0/bin/osv/fields.py:626 :

elif act[0] == 5:
                cr.execute('update '+self._rel+' set '+self._id2+'=null where '+self._id2+'=%s', (id,))

This code leads to the following request :

update my_own_m2m_relation_table set target_id=null where target_id=43

This request is not correct, it leads to an UPDATE 0 each time. It should be :
update my_own_m2m_relation_table set target_id=null where source_id=43
So the correct code could be :

                cr.execute('update '+self._rel+' set '+self._id2+'=null where '+self._id1+'=%s', (id,))

But this is still false !
In the case of a many2many field, we have a separate table dedicated to linking the target values to the source field. So the correct request should be:

delete from my_own_m2m_relation_table where source_id=43

Thus the correct code should be something like:
                cr.execute('update '+self._rel+' set '+self._id2+'=null where '+self._id1+'=%s', (id,))

Related branches

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-server:
status: Confirmed → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

Fix landed in trunk at revno 3599 (revision-id: <email address hidden>)

Thanks for the bug report!

Changed in openobject-server:
status: Fix Committed → Fix Released
senthil (ek-senthil)
information type: Public → Private
Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

This has been fixed a long ago, need not to set private.
Thanks.

information type: Private → Public
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.