[FIX] orm: unlink: when unlinking a record, trigger the computing of
authorThibault Delavallée <tde@openerp.com>
Mon, 19 May 2014 16:12:41 +0000 (18:12 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 19 May 2014 16:12:41 +0000 (18:12 +0200)
function fields for other records in the same model. Previously all function fields in the
current model were not computed for some reason not provided by the history.

We therefore compute effective store_ids on which the various trigerred
function fields will be computed again. Those ids are the ids given
in the store_get storage variable minus the deleted ones.

openerp/osv/orm.py

index ac9e67b..2341b92 100644 (file)
@@ -4067,9 +4067,13 @@ class BaseModel(object):
                 ir_values_obj.unlink(cr, uid, ir_value_ids, context=context)
 
         for order, object, store_ids, fields in result_store:
-            if object != self._name:
+            if object == self._name:
+                effective_store_ids = list(set(store_ids) - set(ids))
+            else:
+                effective_store_ids = store_ids
+            if effective_store_ids:
                 obj = self.pool.get(object)
-                cr.execute('select id from '+obj._table+' where id IN %s', (tuple(store_ids),))
+                cr.execute('select id from '+obj._table+' where id IN %s', (tuple(effective_store_ids),))
                 rids = map(lambda x: x[0], cr.fetchall())
                 if rids:
                     obj._store_set_values(cr, uid, rids, fields, context)