From bbe7cdf05f969c59c01cef424796036ea80b6aa7 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 23 Feb 2017 13:33:39 +0100 Subject: [PATCH] [IMP] sale_margin: lint uninstall hook --- addons/sale_margin/__init__.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/addons/sale_margin/__init__.py b/addons/sale_margin/__init__.py index 59c0d9d02a1..c59fd8d71e9 100644 --- a/addons/sale_margin/__init__.py +++ b/addons/sale_margin/__init__.py @@ -3,19 +3,17 @@ from functools import partial import openerp from openerp import api, SUPERUSER_ID -import sale_margin -import report +import sale_margin # noqa +import report # noqa def uninstall_hook(cr, registry): - def recreate_view(dbname): - db_registry = openerp.modules.registry.RegistryManager.new(dbname) - with api.Environment.manage(), db_registry.cursor() as cr: - env = api.Environment(cr, SUPERUSER_ID, {}) - if 'sale.report' in env: - env['ir.module.module'].search([('name', '=', 'sale_margin')]).state - env['sale.report'].init() + def recreate_view(dbname): + db_registry = openerp.modules.registry.RegistryManager.new(dbname) + with api.Environment.manage(), db_registry.cursor() as cr: + env = api.Environment(cr, SUPERUSER_ID, {}) + if 'sale.report' in env: + env['sale.report'].init() - - cr.after("commit", partial(recreate_view, cr.dbname)) \ No newline at end of file + cr.after("commit", partial(recreate_view, cr.dbname))