[MOD] hr_timesheet : employees timesheet report and wizard, instead of selecting user, from employee report is generated

bzr revid: vir@tinyerp.com-20101004120012-rzi4tyn14ixw4aoe
This commit is contained in:
Vir (Open ERP) 2010-10-04 17:30:12 +05:30
parent 12dad77b6a
commit afe202a227
3 changed files with 12 additions and 10 deletions

View File

@ -59,7 +59,7 @@ def emp_create_xml(cr, id, som, eom):
time_xml = ([xml % (day, amount) for day, amount in month.iteritems()])
# Computing the employee
cr.execute("select name from res_users where id=%s", (id,))
cr.execute("select name from resource_resource where id=%s", (id,))
emp = cr.fetchone()[0]
# Computing the xml
@ -91,9 +91,11 @@ class report_custom(report_rml):
date_xml.append('<cols>2.5cm%s,2cm</cols>\n' % (',0.7cm' * lengthmonth(som.year, som.month)))
emp_xml=''
for id in data['form']['user_ids']:
emp_xml += emp_create_xml(cr, id, som, eom)
emp_obj = pooler.get_pool(cr.dbname).get('hr.employee')
for id in data['form']['employee_ids']:
user = emp_obj.browse(cr, uid, id).user_id.id
if user:
emp_xml += emp_create_xml(cr, id, som, eom)
# Computing the xml
#Without this, report don't show non-ascii characters (TO CHECK)
date_xml = '\n'.join(date_xml)

View File

@ -30,7 +30,7 @@ class analytical_timesheet_employees(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_ids': fields.many2many('res.users', 'timesheet_users_rel', 'timesheet_id', 'user_id', 'Users', required=True)
'employee_ids': fields.many2many('hr.employee', 'timesheet_employee_rel', 'timesheet_id', 'employee_id', 'employees', required=True)
}
_defaults = {
@ -55,4 +55,4 @@ class analytical_timesheet_employees(osv.osv_memory):
analytical_timesheet_employees()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -8,16 +8,16 @@
<field name="model">hr.analytical.timesheet.users</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Employees Timesheet">
<form string="Monthly Employees Timesheet">
<group height="260" width="460">
<group colspan="4">
<separator string="This wizard will print monthly timesheet of employees" colspan="4"/>
<field name="month"/>
<field name="year"/>
<field name="user_ids" colspan="4"/>
<separator string="Employees" colspan="4"/>
<field name="employee_ids" colspan="4" nolabel="1"/>
</group>
<separator colspan="4"/>
<group colspan="4" col="6">
<group colspan="4">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-print" string="Print" name="print_report" type="object"/>
</group>