details:   https://code.tryton.org/tryton/commit/3e4282b4e9ab
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Mon Mar 16 17:26:59 2026 +0100
description:
        Set the overpaying statement line related_to type to account.invoice

        We can infer that the extra amount will be used to pay another invoice 
so we
        might as well help a little bit the user to select the right one

        Closes #14683
diffstat:

 modules/account_statement/statement.py |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (15 lines):

diff -r 0b4fca5fe44b -r 3e4282b4e9ab modules/account_statement/statement.py
--- a/modules/account_statement/statement.py    Mon Mar 16 15:54:38 2026 +0100
+++ b/modules/account_statement/statement.py    Mon Mar 16 17:26:59 2026 +0100
@@ -288,7 +288,10 @@
                             except AttributeError:
                                 pass
                         new_line.amount = line.amount + amount_to_pay
-                        new_line.invoice = None
+                        # As the line is overpaying an invoice we can assume
+                        # that the additional line will be used to pay an
+                        # invoice
+                        new_line.related_to = ('account.invoice', -1)
                         line_offset += 1
                         lines.insert(index + line_offset, new_line)
                         invoice_id2amount_to_pay[line.invoice.id] = Decimal(0)

Reply via email to