From a3d806ffa048ac79c80ecb8f3b29d3e6506f0c5d Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 8 Jan 2016 14:59:38 +0100 Subject: [PATCH] mis_builder: fix use of api.constrains --- mis_builder/models/mis_builder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 7e4a7964..423fb94d 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -31,7 +31,7 @@ import traceback import pytz -from openerp import api, fields, models, _ +from openerp import api, fields, models, _, exceptions from openerp.tools.safe_eval import safe_eval from .aep import AccountingExpressionProcessor as AEP @@ -123,7 +123,8 @@ class MisReportKpi(models.Model): @api.one @api.constrains('name') def _check_name(self): - return _is_valid_python_var(self.name) + if not _is_valid_python_var(self.name): + raise exception.Warning(_('The name must be a valid python identifier')) @api.onchange('name') def _onchange_name(self): @@ -258,7 +259,8 @@ class MisReportQuery(models.Model): @api.one @api.constrains('name') def _check_name(self): - return _is_valid_python_var(self.name) + if not _is_valid_python_var(self.name): + raise exception.Warning(_('The name must be a valid python identifier')) class MisReport(models.Model):