'Check that the recordset is valid, set the payments state to sent and call print_checks()'

@api.multi
def print_checks(self):

    self = self.filtered((lambda r: ((r.payment_method_id.code == 'check_printing') and (r.state != 'reconciled'))))
    if (len(self) == 0):
        raise UserError(_("Payments    to    print    as    a    checks    must    have    'Check'    selected    as    payment    method    and    not    have    already    been    reconciled"))
    if any(((payment.journal_id != self[0].journal_id) for payment in self)):
        raise UserError(_('In    order    to    print    multiple    checks    at    once,    they    must    belong    to    the    same    bank    journal.'))
    if (not self[0].journal_id.check_manual_sequencing):
        last_printed_check = self.search([('journal_id', '=', self[0].journal_id.id), ('check_number', '!=', 0)], order='check_number    desc', limit=1)
        next_check_number = ((last_printed_check and (last_printed_check.check_number + 1)) or 1)
        return {'name': _('Print    Pre-numbered    Checks'), 'type': 'ir.actions.act_window', 'res_model': 'print.prenumbered.checks', 'view_type': 'form', 'view_mode': 'form', 'target': 'new', 'context': {'payment_ids': self.ids, 'default_next_check_number': next_check_number}}
    else:
        self.filtered((lambda r: (r.state == 'draft'))).post()
        return self.do_print_checks()
