From f4a69ffb2520afdde196b660ba15ed2d0da10ef5 Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Thu, 28 Feb 2008 14:14:24 +0100 Subject: [PATCH] Order the to_delete list at read time instead of sorting it later --- trytond/tools/convert.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/trytond/tools/convert.py b/trytond/tools/convert.py index 354e63fe18..d4fea4678c 100644 --- a/trytond/tools/convert.py +++ b/trytond/tools/convert.py @@ -456,8 +456,11 @@ class TrytondXmlHandler(sax.handler.ContentHandler): process. The records that are not encountered are deleted from the database in post_import.""" + # Fetch the data in id descending order to avoid depedendcy + # problem when the corresponding recordds will be deleted: module_data_ids = self.modeldata_obj.search( - self.cursor, self.user, [('module','=',self.module)] + self.cursor, self.user, [('module','=',self.module)], + order="id desc", ) return [(rec.id,rec.model,rec.db_id) for rec in self.modeldata_obj.browse( self.cursor, self.user, module_data_ids)] @@ -624,10 +627,6 @@ def post_import(cursor, module, to_delete): pool = pooler.get_pool(cursor.dbname) modeldata_obj = pool.get("ir.model.data") - # Sort by model_data id descending and thus avoiding most - # dependency problems: - to_delete.sort(key= lambda x : -x[0]) - for mdata_id, model,db_id in to_delete: # Whe skip transitions, they will be deleted with the