I created invoice through a customized button, and wanted that 'open' will be automatically it's state once it's created. Current output, 'paid' is the state. Hope you can help me, thank you.
Here's my code:
@api.multi
def create_invoice(self,count):
# print 'create_invoice'
customer = self.partner_id.id
product = self.env['product.template'].search([('default_code', '=', 'HOST')])
account_id = self.env['account.account'].search([('internal_type','=','receivable')]).id
journal_id = self.env['account.journal'].search([('code','=','INV')]).id
# create invoice
invoice_header = self.env['account.invoice'].create({
'partner_id': customer,
# 'number': self.get_invoice_sequence(),
# 'date_invoice': today_date,
'account_id': account_id,
'journal_id': journal_id,
'user_id': self.env.user.id,
})
invoice_lines = self.env['account.invoice.line'].create({
'invoice_id': invoice_header.id,
'product_id': product[0].id,
'name':product[0].name,
'quantity': count,
'price_unit': product[0].list_price,
'account_id': account_id,
})
invoice_header.action_invoice_open()