[MOD] hr_timesheet : employee timesheet report and wizard, instead of selecting user, from employee report is generated
bzr revid: vir@tinyerp.com-20101004104735-hlo0co1gt7z3rx7i
This commit is contained in:
@@ -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('</account>')
|
||||
|
||||
# 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
|
||||
|
||||
@@ -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:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
<field name="model">hr.analytical.timesheet.employee</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Employee Timesheet">
|
||||
<form string="Monthly Employee Timesheet">
|
||||
<group colspan="4">
|
||||
<separator string="This wizard will print monthly timesheet of employee" colspan="4"/>
|
||||
<field name="month"/>
|
||||
<field name="year"/>
|
||||
<field name="user_id" colspan="3"/>
|
||||
<field name="employee_id" colspan="3"/>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
|
||||
Reference in New Issue
Block a user