From 8d932ff6ff80ce17839209e87af7d253f0d24fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Mon, 16 Mar 2026 17:26:59 +0100 Subject: [PATCH] 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 --- modules/account_statement/statement.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/account_statement/statement.py b/modules/account_statement/statement.py index 6606d3cfce..d8ec18ae40 100644 --- a/modules/account_statement/statement.py +++ b/modules/account_statement/statement.py @@ -288,7 +288,10 @@ class Statement(Workflow, ModelSQL, ModelView, ChatMixin): 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)