Change @api.one to @api.multi
@api.one can NOT be used here, as it iterates automatically over "ids" recordset and puts result of each iteration into the python list, finally the list is returned. so in your case, what is really returned from your function because of @api.one, that is:
[ {
'type': 'ir.actions.act_window',
'res_model': 'leave.csv.report',
'view_mode': 'form',
'view_type': 'form',
'res_id': self.id,
'views': [(False, 'form')],
'target': 'new',
} ]
that's why it does not work. you can get it worked either with @api.multi or @api.model,
@api.multi will still work, as self.id will take id of the first record from recordset, so you have NOT to change function body:
@api.multi
def generate_report(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'leave.csv.report',
'view_mode': 'form',
'view_type': 'form',
'res_id': self.id,
'views': [(False, 'form')],
'target': 'new',
}