[FIX] sale_margin: uninstall_hook

When uninstalling the module sale_margin, the view 'sale_report' was deleted
because this view was overwritten  in this module.

But the module sale still uses the 'sale_report' view so it raised an error
each time this view was required.

opw:709328
This commit is contained in:
Goffin Simon
2017-02-22 14:46:26 +01:00
parent f0178abe9b
commit 36b7d980ca
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -1,4 +1,21 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from functools import partial
import openerp
from openerp import api, SUPERUSER_ID
import sale_margin
import report
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()
cr.after("commit", partial(recreate_view, cr.dbname))
+1
View File
@@ -18,4 +18,5 @@ Price and Cost Price.
'data':['security/ir.model.access.csv','sale_margin_view.xml'],
'auto_install': False,
'installable': True,
'uninstall_hook': "uninstall_hook",
}