Commit cc0283f3 authored by Cédric Krier's avatar Cédric Krier
Browse files

Compute history datetime only when invoice has been actually posted

Relying only on the numbered_at being filled make the posting process use the
history data once the number has been set on the invoice. But as the move
computation (with the payment term) happens after, they are done using the
history data (which maybe corrupted see #11980).

Closes #11982
parent e0208968107b
Pipeline #61586 passed with stages
in 9 minutes and 33 seconds
......@@ -64,8 +64,9 @@
Greatest(table.numbered_at, party.create_date,
address.create_date, payment_term.create_date),
where=reduce_ids(, ids)
& (table.numbered_at != Null)))
& (table.numbered_at != Null)
& (table.state.in_(cls._history_states()))))
return datetimes
......@@ -68,7 +69,11 @@
return datetimes
def _history_states(cls):
return ['posted', 'paid', 'cancelled']
def set_number(cls, invoices):
numbered = [i for i in invoices if not i.number or not i.numbered_at]
super(Invoice, cls).set_number(invoices)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment