@@ -120,11 +120,12 @@ def module_installed(cr, module):
120
120
return modules_installed (cr , module )
121
121
122
122
123
- def uninstall_module (cr , module ):
123
+ def uninstall_module (cr , module , remove_model_inherits = False ):
124
124
"""
125
125
Uninstall and remove all records owned by a module.
126
126
127
127
:param str module: name of the module to uninstall
128
+ :param bool remove_model_inherits: whether to remove inherits of the module's models
128
129
"""
129
130
cr .execute ("SELECT id FROM ir_module_module WHERE name=%s" , (module ,))
130
131
(mod_id ,) = cr .fetchone () or [None ]
@@ -233,13 +234,13 @@ def uninstall_module(cr, module):
233
234
if model_ids :
234
235
cr .execute ("SELECT model FROM ir_model WHERE id IN %s" , [tuple (model_ids )])
235
236
for (model ,) in cr .fetchall ():
236
- delete_model (cr , model )
237
+ delete_model (cr , model , remove_inherits = remove_model_inherits )
237
238
238
239
if field_ids :
239
240
cr .execute ("SELECT model, name FROM ir_model_fields WHERE id IN %s" , [tuple (field_ids )])
240
241
for model , name in cr .fetchall ():
241
242
if name == "id" :
242
- delete_model (cr , model )
243
+ delete_model (cr , model , remove_inherits = remove_model_inherits )
243
244
else :
244
245
remove_field (cr , model , name )
245
246
@@ -284,14 +285,15 @@ def uninstall_theme(cr, theme, base_theme=None):
284
285
uninstall_module (cr , theme )
285
286
286
287
287
- def remove_module (cr , module ):
288
+ def remove_module (cr , module , remove_model_inherits = False ):
288
289
"""
289
290
Completely remove a module.
290
291
291
292
This operation is equivalent to uninstall and removal of *all* references to
292
293
the module - no trace of it is left in the database.
293
294
294
295
:param str module: name of the module to remove
296
+ :param bool remove_model_inherits: whether to remove inherits of the module's models
295
297
296
298
.. warning::
297
299
Since this function removes *all* data associated to the module. Ensure to
@@ -301,7 +303,7 @@ def remove_module(cr, module):
301
303
# module need to be currently installed and running as deletions
302
304
# are made using orm.
303
305
304
- uninstall_module (cr , module )
306
+ uninstall_module (cr , module , remove_model_inherits = remove_model_inherits )
305
307
cr .execute ("DELETE FROM ir_module_module_dependency WHERE name=%s" , (module ,))
306
308
cr .execute ("DELETE FROM ir_module_module WHERE name=%s RETURNING id" , (module ,))
307
309
if cr .rowcount :
0 commit comments