summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2018-02-22 09:17:23 +0100
committerAdrian Torres <adt@odoo.com>2018-02-22 09:55:59 +0100
commit8e7aaf8c82df80b28fa5f3fc7973ef9e49f29d97 (patch)
tree954a7cccae0e8b08ea7f0dfd08504bb3118cafd1
parent97cae87812e60b63d61e09b5974c1e50c316de16 (diff)
[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
-rw-r--r--addons/account_invoicing/__init__.py9
-rw-r--r--addons/account_invoicing/__manifest__.py1
-rw-r--r--addons/sale_management/__init__.py9
-rw-r--r--addons/sale_management/__manifest__.py1
4 files changed, 20 insertions, 0 deletions
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',
}