Merge lp:~openerp-dev/openobject-server/7.0-uninstall-module-constraint-mat into lp:openobject-server/7.0

Proposed by Martin Trigaux (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/7.0-uninstall-module-constraint-mat
Merge into: lp:openobject-server/7.0
Diff against target: 43 lines (+10/-7)
2 files modified
openerp/addons/base/ir/ir_model.py (+10/-3)
openerp/addons/base/module/module.py (+0/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/7.0-uninstall-module-constraint-mat
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Pending
Review via email: mp+213245@code.launchpad.net

Description of the change

When uninstalling a module, remove the ir.model.constraint after removing the non-model records and before fields and model definition

To post a comment you must log in.

Unmerged revisions

5268. By Martin Trigaux (OpenERP)

[FIX] uninstall: when uninstalling a module, remove the ir.model.constraint after removing the non-model records and before fields and model definition

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp/addons/base/ir/ir_model.py'
--- openerp/addons/base/ir/ir_model.py 2014-02-24 16:19:18 +0000
+++ openerp/addons/base/ir/ir_model.py 2014-03-28 12:26:38 +0000
@@ -1085,13 +1085,20 @@
10851085
1086 # Remove non-model records first, then model fields, and finish with models1086 # Remove non-model records first, then model fields, and finish with models
1087 unlink_if_refcount((model, res_id) for model, res_id in to_unlink1087 unlink_if_refcount((model, res_id) for model, res_id in to_unlink
1088 if model not in ('ir.model','ir.model.fields'))1088 if model not in ('ir.model','ir.model.fields','ir.model.constraint'))
1089 unlink_if_refcount((model, res_id) for model, res_id in to_unlink
1090 if model == 'ir.model.constraint')
1091
1092 ir_module_module = self.pool['ir.module.module']
1093 ir_model_constraint = self.pool['ir.model.constraint']
1094 modules_to_remove_ids = ir_module_module.search(cr, uid, [('name', 'in', modules_to_remove)], context=context)
1095 constraint_ids = ir_model_constraint.search(cr, uid, [('module', 'in', modules_to_remove_ids)], context=context)
1096 ir_model_constraint._module_data_uninstall(cr, uid, constraint_ids, context)
1097
1089 unlink_if_refcount((model, res_id) for model, res_id in to_unlink1098 unlink_if_refcount((model, res_id) for model, res_id in to_unlink
1090 if model == 'ir.model.fields')1099 if model == 'ir.model.fields')
10911100
1092 ir_model_relation = self.pool.get('ir.model.relation')1101 ir_model_relation = self.pool.get('ir.model.relation')
1093 ir_module_module = self.pool.get('ir.module.module')
1094 modules_to_remove_ids = ir_module_module.search(cr, uid, [('name', 'in', modules_to_remove)])
1095 relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove_ids)])1102 relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove_ids)])
1096 ir_model_relation._module_data_uninstall(cr, uid, relation_ids, context)1103 ir_model_relation._module_data_uninstall(cr, uid, relation_ids, context)
10971104
10981105
=== modified file 'openerp/addons/base/module/module.py'
--- openerp/addons/base/module/module.py 2014-01-14 15:44:26 +0000
+++ openerp/addons/base/module/module.py 2014-03-28 12:26:38 +0000
@@ -432,11 +432,7 @@
432 including the deletion of all database structures created by the module:432 including the deletion of all database structures created by the module:
433 tables, columns, constraints, etc."""433 tables, columns, constraints, etc."""
434 ir_model_data = self.pool.get('ir.model.data')434 ir_model_data = self.pool.get('ir.model.data')
435 ir_model_constraint = self.pool.get('ir.model.constraint')
436 modules_to_remove = [m.name for m in self.browse(cr, uid, ids, context)]435 modules_to_remove = [m.name for m in self.browse(cr, uid, ids, context)]
437 modules_to_remove_ids = [m.id for m in self.browse(cr, uid, ids, context)]
438 constraint_ids = ir_model_constraint.search(cr, uid, [('module', 'in', modules_to_remove_ids)])
439 ir_model_constraint._module_data_uninstall(cr, uid, constraint_ids, context)
440 ir_model_data._module_data_uninstall(cr, uid, modules_to_remove, context)436 ir_model_data._module_data_uninstall(cr, uid, modules_to_remove, context)
441 self.write(cr, uid, ids, {'state': 'uninstalled'})437 self.write(cr, uid, ids, {'state': 'uninstalled'})
442 return True438 return True