I created a wizard to print a payslip report in a specific way i designed. The payslip report works quite well.
However, I couldn't get it to filter by the specific date selected. It prints every information .
My wizard code is below
class ReportWizard(osv.osv_memory):
_name = 'bluspiral.sche.schedule'
# _inherit = 'account.invoice'
_description = 'Cash Payroll Schedule'
_columns = {
'date_from': fields.date('Date From', required=True),
'date_to': fields.date('Date To', required=True),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-%m-01'),
'date_to': lambda *a: str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10],
}
def print_payroll_schedule_report(self, cr, uid, ids, context=None):
datas = {}
if context is None:
context = {}
data = self.read(cr, uid, ids,['date_from', 'date_to'], context=context)
date_from = data[0]['date_from']
date_to = data[0]['date_to']
obj = self.pool['hr.payslip']
ids = obj.search(cr, uid, [('date_from','>=',date_from),('date_from','<=',date_to)])
datas = {
'ids': ids,
'model': 'bluspiral.sche.schedule.template',
'form': data[0]
}
return self.pool['report'].get_action( cr, uid, [], 'bluspiral_sche.cash_report', data=datas, context=context )
Any ideas??