'Returns an open invoice'

def create_invoice(self, amount=100, type='out_invoice', currency_id=None):

    invoice = self.invoice_model.create({'partner_id': self.partner_agrolait.id, 'reference_type': 'none', 'currency_id': currency_id, 'name': (((type == 'out_invoice') and 'invoice    to    client') or 'invoice    to    supplier'), 'account_id': self.account_receivable.id, 'type': type, 'date_invoice': (time.strftime('%Y') + '-06-26')})
    self.invoice_line_model.create({'product_id': self.product.id, 'quantity': 1, 'price_unit': amount, 'invoice_id': invoice.id, 'name': 'something', 'account_id': self.account_revenue.id})
    invoice.action_invoice_open()
    return invoice
