From e091efecb844159980d9ca981225a1349c8878a9 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Mon, 13 Jan 2014 17:27:27 +0100 Subject: [PATCH] [FIX] hr_holidays: Use osv.except_osv instead exceptions.Warning, because Warning does not inherit from osv.except_osv and this exception is not catched by the system. bzr revid: stw@openerp.com-20140113162727-5au3iimfz4d1mszw --- addons/hr_holidays/hr_holidays.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index a30b874bd8a..c6133cd4165 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -26,7 +26,6 @@ import math import time from operator import attrgetter -from openerp.exceptions import Warning from openerp import tools from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -437,8 +436,11 @@ class hr_holidays(osv.osv): leave_days = self.pool.get('hr.holidays.status').get_days(cr, uid, [record.holiday_status_id.id], record.employee_id.id, context=context)[record.holiday_status_id.id] if leave_days['remaining_leaves'] < 0 or leave_days['virtual_remaining_leaves'] < 0: # Raising a warning gives a more user-friendly feedback than the default constraint error - raise Warning(_('The number of remaining leaves is not sufficient for this leave type.\n' - 'Please verify also the leaves waiting for validation.')) + raise osv.except_osv( + _('Warning!'), + _('The number of remaining leaves is not sufficient for this leave type.\n' + 'Please verify also the leaves waiting for validation.') + ) return True # -----------------------------