@@ -120,11 +120,12 @@ def module_installed(cr, module):
120120 return modules_installed (cr , module )
121121
122122
123- def uninstall_module (cr , module ):
123+ def uninstall_module (cr , module , remove_model_inherits = False ):
124124 """
125125 Uninstall and remove all records owned by a module.
126126
127127 :param str module: name of the module to uninstall
128+ :param bool remove_model_inherits: whether to remove inherits of the module's models
128129 """
129130 cr .execute ("SELECT id FROM ir_module_module WHERE name=%s" , (module ,))
130131 (mod_id ,) = cr .fetchone () or [None ]
@@ -233,13 +234,13 @@ def uninstall_module(cr, module):
233234 if model_ids :
234235 cr .execute ("SELECT model FROM ir_model WHERE id IN %s" , [tuple (model_ids )])
235236 for (model ,) in cr .fetchall ():
236- delete_model (cr , model )
237+ delete_model (cr , model , remove_inherits = remove_model_inherits )
237238
238239 if field_ids :
239240 cr .execute ("SELECT model, name FROM ir_model_fields WHERE id IN %s" , [tuple (field_ids )])
240241 for model , name in cr .fetchall ():
241242 if name == "id" :
242- delete_model (cr , model )
243+ delete_model (cr , model , remove_inherits = remove_model_inherits )
243244 else :
244245 remove_field (cr , model , name )
245246
@@ -284,14 +285,15 @@ def uninstall_theme(cr, theme, base_theme=None):
284285 uninstall_module (cr , theme )
285286
286287
287- def remove_module (cr , module ):
288+ def remove_module (cr , module , remove_model_inherits = False ):
288289 """
289290 Completely remove a module.
290291
291292 This operation is equivalent to uninstall and removal of *all* references to
292293 the module - no trace of it is left in the database.
293294
294295 :param str module: name of the module to remove
296+ :param bool remove_model_inherits: whether to remove inherits of the module's models
295297
296298 .. warning::
297299 Since this function removes *all* data associated to the module. Ensure to
@@ -301,7 +303,7 @@ def remove_module(cr, module):
301303 # module need to be currently installed and running as deletions
302304 # are made using orm.
303305
304- uninstall_module (cr , module )
306+ uninstall_module (cr , module , remove_model_inherits = remove_model_inherits )
305307 cr .execute ("DELETE FROM ir_module_module_dependency WHERE name=%s" , (module ,))
306308 cr .execute ("DELETE FROM ir_module_module WHERE name=%s RETURNING id" , (module ,))
307309 if cr .rowcount :
0 commit comments