From 055f95ddfe2d9cc6accc7aefb0f4b9de6f9d2d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Fri, 17 Jun 2022 14:47:41 +0000 Subject: [PATCH] [IMP] event: use UserError in search method instead of ValueError In a search method, the error comes from the user and thus the error should be an UserError. ValueError should be used for other cases. closes odoo/odoo#93944 Signed-off-by: Thibault Delavallee (tde) --- addons/event/models/event_event.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/event/models/event_event.py b/addons/event/models/event_event.py index ae19af74c2f..b2d21a57d8f 100644 --- a/addons/event/models/event_event.py +++ b/addons/event/models/event_event.py @@ -7,7 +7,7 @@ import pytz from odoo import _, api, Command, fields, models from odoo.addons.base.models.res_partner import _tz_get from odoo.tools import format_datetime, is_html_empty -from odoo.exceptions import ValidationError +from odoo.exceptions import UserError, ValidationError from odoo.tools.misc import formatLang from odoo.tools.translate import html_translate @@ -329,9 +329,9 @@ class EventEvent(models.Model): def _search_is_ongoing(self, operator, value): if operator not in ['=', '!=']: - raise ValueError(_('This operator is not supported')) + raise UserError(_('This operator is not supported')) if not isinstance(value, bool): - raise ValueError(_('Value should be True or False (not %s)'), value) + raise UserError(_('Value should be True or False (not %s)') % value) now = fields.Datetime.now() if (operator == '=' and value) or (operator == '!=' and not value): domain = [('date_begin', '<=', now), ('date_end', '>', now)]