[IMP] sale_margin: lint uninstall hook

This commit is contained in:
Christophe Simonis
2017-02-23 13:33:39 +01:00
parent 36b7d980ca
commit bbe7cdf05f
+9 -11
View File
@@ -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))
cr.after("commit", partial(recreate_view, cr.dbname))