[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:
@@ -1,2 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# 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})
|
||||||
|
|||||||
@@ -28,4 +28,5 @@ You could use this simplified accounting in case you work with an (external) acc
|
|||||||
'qweb': [
|
'qweb': [
|
||||||
],
|
],
|
||||||
'application': True,
|
'application': True,
|
||||||
|
'uninstall_hook': 'uninstall_hook',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# 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})
|
||||||
|
|||||||
@@ -47,4 +47,5 @@ The Dashboard for the Sales Manager will include
|
|||||||
'views/sale_management_templates.xml',
|
'views/sale_management_templates.xml',
|
||||||
],
|
],
|
||||||
'application': True,
|
'application': True,
|
||||||
|
'uninstall_hook': 'uninstall_hook',
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user