[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).
This commit is contained in:
Adrian Torres
2018-02-05 09:25:08 +01:00
committed by GitHub
parent 352be6b6df
commit 985c224e2f
4 changed files with 24 additions and 0 deletions
+11
View File
@@ -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})
+1
View File
@@ -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',
}
+11
View File
@@ -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})
+1
View File
@@ -47,4 +47,5 @@ The Dashboard for the Sales Manager will include
'views/sale_management_templates.xml',
],
'application': True,
'uninstall_hook': 'uninstall_hook',
}