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
This commit is contained in:
1 parent
5836fd178c
commit
f3b8a9dcd3
1 file changed
+6
-1
@@ -64,10 +64,15 @@ class Invoice(metaclass=PoolMeta):
|
||||
Greatest(table.numbered_at, party.create_date,
|
||||
address.create_date, payment_term.create_date),
|
||||
where=reduce_ids(table.id, ids)
|
||||
& (table.numbered_at != Null)))
|
||||
& (table.numbered_at != Null)
|
||||
& (table.state.in_(cls._history_states()))))
|
||||
datetimes.update(cursor)
|
||||
return datetimes
|
||||
|
||||
@classmethod
|
||||
def _history_states(cls):
|
||||
return ['posted', 'paid', 'cancelled']
|
||||
|
||||
@classmethod
|
||||
def set_number(cls, invoices):
|
||||
numbered = [i for i in invoices if not i.number or not i.numbered_at]
|
||||
|
||||
Reference in new issue
Block a user