Skip to content

Instantly share code, notes, and snippets.

@rvalyi
Last active February 12, 2019 05:18
Show Gist options
  • Select an option

  • Save rvalyi/e09ead3d31ea49aeed694ae3adf7ffbd to your computer and use it in GitHub Desktop.

Select an option

Save rvalyi/e09ead3d31ea49aeed694ae3adf7ffbd to your computer and use it in GitHub Desktop.
/* after running OpenUpgrade to upgrade to a newer Odoo version, when you start Odoo,
you typically have warning logs about modules not found.
You may uninstall them with a command such as
update ir_module_module set state='uninstalled' where name IN (...);
and then clean the databases of the problematic records of these modules with the following scripts:
*/
/* disable view and menus of uninstalled modules: */
delete from ir_ui_view where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.ui.view' and state='uninstalled');
delete from ir_ui_menu where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.ui.menu' and state='uninstalled');
/* delete actions (there might no be active field): */
delete from ir_act_url where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.actions.act_url' and state='uninstalled');
delete from ir_act_window where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.actions.act_window' and state='uninstalled');
delete from ir_act_client where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.actions.client' and state='uninstalled');
delete from ir_act_server where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.actions.server' and state='uninstalled');
delete from ir_actions_todo where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.actions.todo' and state='uninstalled');
/* kill website stuff */
delete from website where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='website' and state='uninstalled');
delete from website_menu where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='website.menu' and state='uninstalled');
/* misc */
update ir_cron set active=False where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.cron' and state='uninstalled'and active=True);
update ir_rule set active=False where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.rule' and state='uninstalled' and active=True);
delete from res_groups where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='res.groups' and state='uninstalled');
delete from mail_alias where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='mail.alias' and state='uninstalled');
delete from mail_channel where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='mail.channel' and state='uninstalled');
delete from mail_template where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='mail.template' and state='uninstalled');
delete from survey_stage where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='survey.stage' and state='uninstalled');
delete from web_planner where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='web.planner' and state='uninstalled');
delete from ir_attachment where id in (select ir_model_data.res_id from ir_model_data join ir_module_module on ir_module_module.name = ir_model_data.module where model='ir.attachment' and state='uninstalled');
/*update res_users set password='admin'; */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment