From 17bf5de2ed35b5e3852253f003222f0a2b5d6b54 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 16 Sep 2012 21:45:36 +0200 Subject: [PATCH] [IMP] better error message bzr revid: fp@openerp.com-20120916194536-s3rckgin6oh703i4 --- addons/hr_timesheet/hr_timesheet.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index bd71f6479bd..a28508be4db 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -137,11 +137,13 @@ class hr_analytic_timesheet(osv.osv): if context is None: context = {} emp_id = emp_obj.search(cr, uid, [('user_id', '=', context.get('user_id', uid))], context=context) - if emp_id: - emp = emp_obj.browse(cr, uid, emp_id[0], context=context) - if emp.journal_id: - return emp.journal_id.id - return False + if not emp_id : + raise osv.except_osv(_('Warning!'), _('Please create an employee for this user, using the menu: Human Resources > Employees.')) + emp = emp_obj.browse(cr, uid, emp_id[0], context=context) + if emp.journal_id: + return emp.journal_id.id + else : + raise osv.except_osv(_('Warning!'), _('No analytic journal defined for \'%s\'.\nYou should assign an analytic journal on the employee form.')%(emp.name)) _defaults = {