diff --git a/addons/hr_timesheet/report/user_timesheet.py b/addons/hr_timesheet/report/user_timesheet.py
index dc048748f46..93c425af995 100644
--- a/addons/hr_timesheet/report/user_timesheet.py
+++ b/addons/hr_timesheet/report/user_timesheet.py
@@ -63,7 +63,7 @@ class report_custom(report_rml):
"and product_uom_id = unit.id "\
"and line.user_id=%s and line.date >= %s and line.date < %s "
"order by line.date",
- (data['form']['user_id'], som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d')))
+ (uid, som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d')))
# Sum attendence by account, then by day
accounts = {}
@@ -97,7 +97,7 @@ class report_custom(report_rml):
account_xml.append('')
# Computing the employee
- cr.execute("select name from res_users where id=%s", (data['form']['user_id'],))
+ cr.execute("select name from res_users where id=%s", (str(uid)))
emp = cr.fetchone()[0]
# Computing the xml
diff --git a/addons/hr_timesheet/wizard/hr_timesheet_print_employee.py b/addons/hr_timesheet/wizard/hr_timesheet_print_employee.py
index 4bcdb614e2f..2983166ad56 100644
--- a/addons/hr_timesheet/wizard/hr_timesheet_print_employee.py
+++ b/addons/hr_timesheet/wizard/hr_timesheet_print_employee.py
@@ -21,6 +21,7 @@
import datetime
from osv import osv, fields
+from tools.translate import _
class analytical_timesheet_employee(osv.osv_memory):
_name = 'hr.analytical.timesheet.employee'
@@ -29,18 +30,24 @@ class analytical_timesheet_employee(osv.osv_memory):
'month': fields.selection([(x, datetime.date(2000, x, 1).strftime('%B')) for x in range(1, 13)],
'Month', required=True),
'year': fields.integer('Year', required=True),
- 'user_id': fields.many2one('res.users', 'User', required=True)
+ 'employee_id': fields.many2one('hr.employee', 'Employee', required=True)
+
}
def _get_user(self, cr, uid, context=None):
+
+ emp_obj = self.pool.get('hr.employee')
if context is None:
context = {}
- return uid
+ emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
+ if not emp_id:
+ raise osv.except_osv(_("Warning"), _("No employee defined for this user"))
+ return emp_id and emp_id[0] or False
_defaults = {
'month': datetime.date.today().month,
'year': datetime.date.today().year,
- 'user_id': _get_user
+ 'employee_id': _get_user
}
def print_report(self, cr, uid, ids, context=None):
@@ -59,4 +66,4 @@ class analytical_timesheet_employee(osv.osv_memory):
}
analytical_timesheet_employee()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml b/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml
index 3b110b52f1d..63e493cfab7 100644
--- a/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml
+++ b/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml
@@ -8,12 +8,11 @@
hr.analytical.timesheet.employee
form
-