There are paid invoices on draft statements

I get this warning message on statement validation. I don’t undestant its meaning. I cannot add an invoice in a Paid state when creating a statement line from Origins. So I don’t see how I could have some paid invoices…

Is there a way to find which invoices are paid among the ones linked to the statement lines?

I don’t see such message in current code, so just guessing.

I think there are several possibilities (not checked if all are possible or not):

  • you added the same invoice (not paid) several time, and on validation, it marks the first occurence as “paid” and can’t for the second
  • you added an invoice (not paid) in statement, and next you paid it in some way. when you want to validate the statement, the invoice is alread paid and validation step complaint

https://hg.tryton.org/modules/account_statement/file/tip/statement.py#l508

you added an invoice (not paid) in statement, and next you paid it in some way. when you want to validate the statement, the invoice is alread paid and validation step complaint

We don’t have another mean to pay invoices than statements… so that seems highly improbable.

Thanks to point it to me.

The text associated to this message should be The validation of the statements will remove paid invoices from other statements.

It is why I didn’t found it.

invoice are in paid state as soon the move is reconciliated.

The message probably changed after 5.0 to which I’m stuck.
Thks for helping, i’ll dig on the invoices, maybe one was already linked in a previous statement.

if you have lot of invoices to check, you could try the following proteus script:

Statement = Model.get('account.statement')
for statement in Statement.find([('state','=','draft')]):
  for line in statement.lines:
    if line.invoice and line.invoice.state == 'paid':
      print(line.invoice.number, "is paid")

it will walk across all ‘draft’ statements and print any invoice number that is already paid.

Thks, I tested: the statement raising the warning has no invoice marked as Paid nor any invoice used twice…
Tried to stick to the code in 5.0 statement:

StatementLine = Model.get('account.statement.line')
common_lines = StatementLine.find([
                        ('statement.state', '=', 'draft'),
                        ('invoice.state', '=', 'paid'),
                        ])
 len(common_lines)
>>> 0

This test can not show you the problem. Because the invoice is being paid by the statement that is validated. But the invoice is also referenced on another draft statement.
But you can force the validation, Tryton will just remove the invoice from the other draft statement line.