Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
cc0283f3 by Cédric Krier at 2023-01-02T13:16:07+01:00
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
- - - - -


1 changed file:

- modules/account_invoice_history/account.py


Changes:

=====================================
modules/account_invoice_history/account.py
=====================================
@@ -64,8 +64,9 @@
                     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
@@ -68,7 +69,11 @@
             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]
         super(Invoice, cls).set_number(invoices)



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/cc0283f3af8479724588d515a77b7ced7dd2e6bf

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/cc0283f3af8479724588d515a77b7ced7dd2e6bf
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to