|
|
@ -203,24 +203,18 @@ class BiSQLView(models.Model): |
|
|
|
for sql_view in self: |
|
|
|
if sql_view.state in ('model_valid', 'ui_valid'): |
|
|
|
# Drop SQL View (and indexes by cascade) |
|
|
|
if sql_view.is_materialized: |
|
|
|
sql_view._drop_view() |
|
|
|
|
|
|
|
# Drop ORM |
|
|
|
sql_view._drop_model_and_fields() |
|
|
|
|
|
|
|
if sql_view.tree_view_id: |
|
|
|
sql_view.tree_view_id.unlink() |
|
|
|
if sql_view.graph_view_id: |
|
|
|
sql_view.graph_view_id.unlink() |
|
|
|
if sql_view.pivot_view_id: |
|
|
|
sql_view.pivot_view_id.unlink() |
|
|
|
if sql_view.search_view_id: |
|
|
|
sql_view.search_view_id.unlink() |
|
|
|
if sql_view.action_id: |
|
|
|
sql_view.action_id.unlink() |
|
|
|
if sql_view.menu_id: |
|
|
|
sql_view.menu_id.unlink() |
|
|
|
if sql_view.rule_id: |
|
|
|
sql_view.rule_id.unlink() |
|
|
|
if sql_view.cron_id: |
|
|
|
sql_view.cron_id.unlink() |
|
|
@ -416,14 +410,9 @@ class BiSQLView(models.Model): |
|
|
|
@api.multi |
|
|
|
def _drop_view(self): |
|
|
|
for sql_view in self: |
|
|
|
try: |
|
|
|
self._log_execute( |
|
|
|
"DROP %s VIEW IF EXISTS %s" % ( |
|
|
|
sql_view.materialized_text, sql_view.view_name)) |
|
|
|
except ProgrammingError as e: |
|
|
|
# If it is not a materialized view will raise an error, |
|
|
|
# and we pass. |
|
|
|
continue |
|
|
|
sql_view.size = False |
|
|
|
|
|
|
|
@api.multi |
|
|
@ -560,7 +549,8 @@ class BiSQLView(models.Model): |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def _refresh_materialized_view(self): |
|
|
|
for sql_view in self.filtered(lambda v: v.is_materialized == True): |
|
|
|
for sql_view in self: |
|
|
|
if sql_view.is_materialized: |
|
|
|
req = "REFRESH %s VIEW %s" % ( |
|
|
|
sql_view.materialized_text, sql_view.view_name) |
|
|
|
self._log_execute(req) |
|
|
|