summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2018-02-05 09:25:08 +0100
committerGitHub <noreply@github.com>2018-02-05 09:25:08 +0100
commit985c224e2f0fb4e3064db354c3fbb92b9a188918 (patch)
treee49e3a85b6b6ceb07932a8625aac0a1c8dda4315
parent352be6b6dfbdb2ad02f331238c1eec448ff7b955 (diff)
[FIX] sale_management,account_invoicing: proper uninstall
Previous to this commit, installing sale_managmenet/account_invoicing would add some menu items for the `sale/account` module (which contains all the logic for the sale/accounting flow) and it would also install sale/account since it's a dependency, however, horror would strike if one were to go and uninstall sale_management/account_invoicing: nothing happens! This is because these "facade" modules don't actually install anything, and uninstalling an app does not force the uninstallation of its dependencies, thus the `sale/account` module would stay installed, along with the views introduced by the "facade" module. To fix this, we create an uninstall_hook which forces the removal of the ir.ui.menus that the "facade" modules introduce, so that the functionality remains (for modules that depend on it) but it's not user-accessible (because it should only be accessible to users if the facade module is installed).
-rw-r--r--addons/account_invoicing/__init__.py11
-rw-r--r--addons/account_invoicing/__manifest__.py1
-rw-r--r--addons/sale_management/__init__.py11
-rw-r--r--addons/sale_management/__manifest__.py1
4 files changed, 24 insertions, 0 deletions
diff --git a/addons/account_invoicing/__init__.py b/addons/account_invoicing/__init__.py
index 67dee8c60db..91206cf6094 100644
--- a/addons/account_invoicing/__init__.py
+++ b/addons/account_invoicing/__init__.py
@@ -1,2 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.api import Environment, SUPERUSER_ID
+
+
+def uninstall_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': False})
diff --git a/addons/account_invoicing/__manifest__.py b/addons/account_invoicing/__manifest__.py
index 038e76dfb08..103f72fdd12 100644
--- a/addons/account_invoicing/__manifest__.py
+++ b/addons/account_invoicing/__manifest__.py
@@ -28,4 +28,5 @@ You could use this simplified accounting in case you work with an (external) acc
'qweb': [
],
'application': True,
+ 'uninstall_hook': 'uninstall_hook',
}
diff --git a/addons/sale_management/__init__.py b/addons/sale_management/__init__.py
index 67dee8c60db..1b2e5977577 100644
--- a/addons/sale_management/__init__.py
+++ b/addons/sale_management/__init__.py
@@ -1,2 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.api import Environment, SUPERUSER_ID
+
+
+def uninstall_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': False})
diff --git a/addons/sale_management/__manifest__.py b/addons/sale_management/__manifest__.py
index b498649e819..4202ac31f78 100644
--- a/addons/sale_management/__manifest__.py
+++ b/addons/sale_management/__manifest__.py
@@ -47,4 +47,5 @@ The Dashboard for the Sales Manager will include
'views/sale_management_templates.xml',
],
'application': True,
+ 'uninstall_hook': 'uninstall_hook',
}