[FIX] account: set inv state to 'open' when unreconciling in 'in_payment'

- Check post_at_bank_rec on bank journal.
- Create an invoice of amount=x
- Register a payment of amount=x using the bank journal
(invoice state is now 'in_payment')
- unreconcile the payment

... The invoice state is still 'in_payment' instead of going back to 'open'.
This commit is contained in:
Laurent Smet
2018-09-26 15:34:21 +02:00
parent 326dabce09
commit c1954ba9c6
+2 -2
View File
@@ -528,7 +528,7 @@ class AccountInvoice(models.Model):
reconciled = self.filtered(lambda invoice: invoice.reconciled)
not_reconciled = self - reconciled
(reconciled & pre_reconciled).filtered(lambda invoice: invoice.state == 'open').action_invoice_paid()
(not_reconciled & pre_not_reconciled).filtered(lambda invoice: invoice.state == 'paid').action_invoice_re_open()
(not_reconciled & pre_not_reconciled).filtered(lambda invoice: invoice.state in ('in_payment', 'paid')).action_invoice_re_open()
return res
@api.model
@@ -916,7 +916,7 @@ class AccountInvoice(models.Model):
@api.multi
def action_invoice_re_open(self):
if self.filtered(lambda inv: inv.state != 'paid'):
if self.filtered(lambda inv: inv.state not in ('in_payment', 'paid')):
raise UserError(_('Invoice must be paid in order to set it to register payment.'))
return self.write({'state': 'open'})