From 8e7aaf8c82df80b28fa5f3fc7973ef9e49f29d97 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Thu, 22 Feb 2018 09:17:23 +0100 Subject: [PATCH] [FIX] sale_management/account_invoicing: properly reinstall Commit 985c224 introduced a way to properly uninstall these two modules, however if a user were to reinstall them the views would stay inactive, in the case of sale_management this would mean some menus were missing, in the case of account_invoicing this meant that not even the top-level menu would not appear, effectively misleading users into thinking the module was not installed. The solution is to create a post_init_hook (to ensure that all potentially missing menus are already installed) that activates the previously deactivated menus. Fixes #23245 --- addons/account_invoicing/__init__.py | 9 +++++++++ addons/account_invoicing/__manifest__.py | 1 + addons/sale_management/__init__.py | 9 +++++++++ addons/sale_management/__manifest__.py | 1 + 4 files changed, 20 insertions(+) diff --git a/addons/account_invoicing/__init__.py b/addons/account_invoicing/__init__.py index 91206cf6094..371975a409a 100644 --- a/addons/account_invoicing/__init__.py +++ b/addons/account_invoicing/__init__.py @@ -11,3 +11,12 @@ def uninstall_hook(cr, registry): ('module', '=', 'account') ]).mapped('res_id') env['ir.ui.menu'].browse(res_ids).update({'active': False}) + + +def post_init_hook(cr, registry): + env = Environment(cr, SUPERUSER_ID, {}) + res_ids = env['ir.model.data'].search([ + ('model', '=', 'ir.ui.menu'), + ('module', '=', 'account'), + ]).mapped('res_id') + env['ir.ui.menu'].browse(res_ids).update({'active': True}) diff --git a/addons/account_invoicing/__manifest__.py b/addons/account_invoicing/__manifest__.py index 103f72fdd12..789d02c43d3 100644 --- a/addons/account_invoicing/__manifest__.py +++ b/addons/account_invoicing/__manifest__.py @@ -29,4 +29,5 @@ You could use this simplified accounting in case you work with an (external) acc ], 'application': True, 'uninstall_hook': 'uninstall_hook', + 'post_init_hook': 'post_init_hook', } diff --git a/addons/sale_management/__init__.py b/addons/sale_management/__init__.py index 1b2e5977577..086ab956265 100644 --- a/addons/sale_management/__init__.py +++ b/addons/sale_management/__init__.py @@ -11,3 +11,12 @@ def uninstall_hook(cr, registry): ('module', '=', 'sale') ]).mapped('res_id') env['ir.ui.menu'].browse(res_ids).update({'active': False}) + + +def post_init_hook(cr, registry): + env = Environment(cr, SUPERUSER_ID, {}) + res_ids = env['ir.model.data'].search([ + ('model', '=', 'ir.ui.menu'), + ('module', '=', 'sale'), + ]).mapped('res_id') + env['ir.ui.menu'].browse(res_ids).update({'active': True}) diff --git a/addons/sale_management/__manifest__.py b/addons/sale_management/__manifest__.py index 4202ac31f78..c4584b0acc9 100644 --- a/addons/sale_management/__manifest__.py +++ b/addons/sale_management/__manifest__.py @@ -48,4 +48,5 @@ The Dashboard for the Sales Manager will include ], 'application': True, 'uninstall_hook': 'uninstall_hook', + 'post_init_hook': 'post_init_hook', }