From 43866855b21a32f4ed31c971f524095f4425e3f4 Mon Sep 17 00:00:00 2001 From: mreficent Date: Fri, 31 Aug 2018 21:07:26 +0200 Subject: [PATCH] [FIX] ir.cron relation --- bi_sql_editor/models/bi_sql_view.py | 12 ++++++++---- bi_sql_editor/views/view_bi_sql_view.xml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bi_sql_editor/models/bi_sql_view.py b/bi_sql_editor/models/bi_sql_view.py index 7e96dee3..9241729c 100644 --- a/bi_sql_editor/models/bi_sql_view.py +++ b/bi_sql_editor/models/bi_sql_view.py @@ -232,7 +232,7 @@ class BiSQLView(models.Model): if sql_view.state != 'sql_valid': raise UserError(_( "You can only process this action on SQL Valid items")) - # Create ORM and acess + # Create ORM and access sql_view._create_model_and_fields() sql_view._create_model_access() @@ -342,9 +342,9 @@ class BiSQLView(models.Model): 'user_id': SUPERUSER_ID, 'model_id': self.env['ir.model'].search([ ('model', '=', self._name)], limit=1).id, - 'function': '_refresh_materialized_view_cron', + 'state': 'code', + 'code': 'model._refresh_materialized_view_cron(%s)' % self.ids, 'numbercall': -1, - 'args': repr(([self.id],)) } @api.multi @@ -610,7 +610,11 @@ class BiSQLView(models.Model): @api.model def _refresh_materialized_view_cron(self, view_ids): - sql_views = self.browse(view_ids) + sql_views = self.search([ + ('is_materialized', '=', True), + ('state', 'in', ['model_valid', 'ui_valid']), + ('id', 'in', view_ids), + ]) return sql_views._refresh_materialized_view() @api.multi diff --git a/bi_sql_editor/views/view_bi_sql_view.xml b/bi_sql_editor/views/view_bi_sql_view.xml index b27e73b8..ef64a20b 100644 --- a/bi_sql_editor/views/view_bi_sql_view.xml +++ b/bi_sql_editor/views/view_bi_sql_view.xml @@ -38,7 +38,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). help="This will try to create an SQL View, based on the SQL request and the according Transient Model and fields, based on settings"/>