[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
This commit is contained in:
Adrian Torres
2018-02-22 09:55:59 +01:00
parent 97cae87812
commit 8e7aaf8c82
4 changed files with 20 additions and 0 deletions
+9
View File
@@ -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})
+1
View File
@@ -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',
}
+9
View File
@@ -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})
+1
View File
@@ -48,4 +48,5 @@ The Dashboard for the Sales Manager will include
],
'application': True,
'uninstall_hook': 'uninstall_hook',
'post_init_hook': 'post_init_hook',
}