diff --git a/modules/account_invoice_history/account.py b/modules/account_invoice_history/account.py index e556c1bff6..47ebcd66d5 100644 --- a/modules/account_invoice_history/account.py +++ b/modules/account_invoice_history/account.py @@ -70,10 +70,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]