lint check. unnecessary queries in uninstall hook.

This commit is contained in:
aheficent
2017-07-28 11:14:21 +02:00
committed by Darshan Patel
parent e04dd70cda
commit cbf6ef59bd
2 changed files with 24 additions and 74 deletions

View File

@@ -10,43 +10,3 @@ def uninstall_hook(cr, registry):
recs = env['bi.sql.view'].search([])
for rec in recs:
rec.button_set_draft()
rec.unlink()
# delete dirty data that could cause problems
# while re-installing the module
# Drop materialized views
cr.execute("""
select relname
from pg_class
where relname like 'x_bi_sql_view%' and relkind='m'
""")
for r in cr.fetchall():
cr.execute("""
DROP MATERIALIZED VIEW %s
""" % r)
cr.execute("""
select relname
from pg_class
where relname like 'x_bi_sql_view%' and relkind='r'
""")
for r in cr.fetchall():
cr.execute("""
DROP TABLE %s
""" % r)
cr.execute("""
select table_name from INFORMATION_SCHEMA.views
where table_name like 'x_bi_sql%'""")
# Drop not materialized views
for v in cr.fetchall():
cr.execute("""
DROP VIEW %s
""" % v)
# Drop table if uninstalling went wrong
cr.execute("""
delete from ir_model_fields where model like 'bi.sql.view%';
delete from ir_model_fields where model like 'bi_sql_%';
delete from ir_model where model like 'x_bi_sql_view.%';
""")