From 206e09ca0eaae07e42fb9365b74a291a19df808a Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 29 Apr 2013 09:35:11 +0200 Subject: [PATCH] [FIX] Always give the cursor back its commit method --- unserialize_field/ir_model_fields.py | 36 +++++++++++++++------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/unserialize_field/ir_model_fields.py b/unserialize_field/ir_model_fields.py index e57e21af4..167d370d3 100644 --- a/unserialize_field/ir_model_fields.py +++ b/unserialize_field/ir_model_fields.py @@ -35,26 +35,28 @@ class ir_model_fields(orm.Model): commit_org = cr.commit cr.commit = lambda *args: None - for this in self.browse(cr, uid, ids, context=context): - pool_obj = self.pool.get(this.model_id.model) - self.create_database_column(cr, uid, pool_obj, this.name, - context=context) - while True: - ids = pool_obj.search( + try: + for this in self.browse(cr, uid, ids, context=context): + pool_obj = self.pool.get(this.model_id.model) + self.create_database_column(cr, uid, pool_obj, this.name, + context=context) + while True: + ids = pool_obj.search( cr, uid, [(this.serialization_field_id.name, '!=', '{}')], offset=offset*step, limit=step, context=context) - if not ids: - break - for data in pool_obj.read(cr, uid, ids, - [this.serialization_field_id.name], - context=context): - self.unserialize_field(cr, uid, pool_obj, data, - this.serialization_field_id.name, - this.name, context=context) - offset += 1 - - cr.commit = commit_org + if not ids: + break + for data in pool_obj.read(cr, uid, ids, + [this.serialization_field_id.name], + context=context): + self.unserialize_field(cr, uid, pool_obj, data, + this.serialization_field_id.name, + this.name, context=context) + offset += 1 + finally: + cr.commit = commit_org + return True def create_database_column(self, cr, uid, pool_obj, field_name,