123456789101112131415161718192021222324252627 |
- # -*- coding: utf-8 -*-
- from openerp import api, fields, models
- class InvoiceChangeStatus(models.Model):
- _inherit = 'account.invoice'
- @api.model
- def update_invoice_state(self, ids):
- updateInvoice = None
- invoiceState = None
- accountInvoice = self.env['account.invoice'].browse(ids)
- if (not accountInvoice):
- return
- if (accountInvoice.residual > 0 and accountInvoice.state == 'paid'):
- invoiceState = 'open'
- if (accountInvoice.residual <= 0 and accountInvoice.state == 'open'):
- invoiceState = 'paid'
- if (invoiceState):
- updateInvoice = accountInvoice.write({'state': invoiceState})
- return True if (updateInvoice) else False
|