flectra/addons/account/wizard/account_invoice_state.py
2018-01-16 02:34:37 -08:00

24 lines
792 B
Python

# -*- coding: utf-8 -*-
from flectra import models, api, _
from flectra.exceptions import UserError
class AccountInvoiceConfirm(models.TransientModel):
"""
This wizard will confirm the all the selected draft invoices
"""
_name = "account.invoice.confirm"
_description = "Confirm the selected invoices"
@api.multi
def invoice_confirm(self):
context = dict(self._context or {})
active_ids = context.get('active_ids', []) or []
for record in self.env['account.invoice'].browse(active_ids):
if record.state != 'draft':
raise UserError(_("Selected invoice(s) cannot be confirmed as they are not in 'Draft' state."))
record.action_invoice_open()
return {'type': 'ir.actions.act_window_close'}