Skip to content

Commit

Permalink
Additional checks for clean upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard deMeester committed Nov 22, 2019
1 parent f42bde6 commit fb8aa80
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bi_sql_editor/models/bi_sql_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from odoo import _, api, fields, models, SUPERUSER_ID
from odoo.exceptions import UserError
from odoo.tools import pycompat, sql
from odoo.tools import pycompat, sql, table_columns
from odoo.addons.base.models.ir_model import IrModel

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -656,6 +656,11 @@ def button_preview_sql_expression(self):
raise UserError('\n'.join(map(lambda x: str(x), res[:100])))

def check_manual_fields(self, model):
if 'model_name' in self._fields and model._name.startswith(self._model_prefix):
# check the fields we need are defined on self, to stop it going
# early on install / startup - particularly problematic during upgrade
if 'group_operator' in table_columns(self.env.cr, 'bi_sql_view_field') and\
'model_name' in self._fields and\
'bi_sql_view_field_ids' in self._fields and\
model._name.startswith(self._model_prefix):
self.search([('model_name', '=', model._name)]
).bi_sql_view_field_ids.adjust_manual_fields(model)

0 comments on commit fb8aa80

Please sign in to comment.