[FIX] Bug 365012 : Made a check before printing a blank report(ref:ach)

bzr revid: jvo@tinyerp.com-20090424054428-we4dk3bpukeqnz8f
This commit is contained in:
Jay (Open ERP)
2009-04-24 11:14:28 +05:30
parent 8575cf3ab5
commit 00a002e314
@@ -22,6 +22,7 @@
import wizard
import time
import pooler
_date_form = '''<?xml version="1.0"?>
<form string="Select a time span">
@@ -38,6 +39,18 @@ _date_fields = {
'max_delay': {'string':'Max. Delay (Min)', 'type':'integer', 'default':lambda *a: 120, 'required':True},
}
def _check_data(self, cr, uid, data, *args):
date_from = data['form']['init_date']
date_to = data['form']['end_date']
emp_ids = (','.join([str(x) for x in data['ids']]))
cr.execute("select id from hr_attendance where employee_id in (%s) and to_char(name,'YYYY-mm-dd')<='%s' and to_char(name,'YYYY-mm-dd')>='%s' and action in ('%s','%s') order by name" %(emp_ids, date_to, date_from, 'sign_in', 'sign_out'))
attendance_ids = [x[0] for x in cr.fetchall()]
if not attendance_ids:
raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
return data['form']
class wiz_attendance(wizard.interface):
states = {
'init': {
@@ -45,7 +58,7 @@ class wiz_attendance(wizard.interface):
'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('print','Print Attendance Report'),('end','Cancel') ]}
},
'print': {
'actions': [],
'actions': [_check_data],
'result': {'type': 'print', 'report': 'hr.attendance.error', 'state':'end'}
}
}