details: https://code.tryton.org/tryton/commit/b8a22af28093
branch: default
user: Cédric Krier <[email protected]>
date: Mon Sep 29 15:37:10 2025 +0200
description:
Allow customization of the payment reference to use
diffstat:
modules/account_payment/payment.py | 26 ++++++++++++++++++++++++++
modules/account_payment/tryton.cfg | 1 +
modules/account_payment_sepa/payment.py | 5 +----
3 files changed, 28 insertions(+), 4 deletions(-)
diffs (69 lines):
diff -r c8cc00c41722 -r b8a22af28093 modules/account_payment/payment.py
--- a/modules/account_payment/payment.py Mon Sep 29 15:33:46 2025 +0200
+++ b/modules/account_payment/payment.py Mon Sep 29 15:37:10 2025 +0200
@@ -510,6 +510,13 @@
except stdnum.exceptions.ValidationError:
return reference
+ @property
+ def reference_used(self):
+ reference = self.reference
+ if not reference and self.line and self.line.move_origin:
+ reference = getattr(self.line.move_origin, 'rec_name', None)
+ return reference
+
@staticmethod
def default_company():
return Transaction().context.get('company')
@@ -795,6 +802,25 @@
line=payment.line.rec_name))
+class Payment_Invoice(metaclass=PoolMeta):
+ __name__ = 'account.payment'
+
+ @property
+ def reference_used(self):
+ pool = Pool()
+ Invoice = pool.get('account.invoice')
+ reference = super().reference_used
+ if (not self.reference
+ and self.line
+ and isinstance(self.line.move_origin, Invoice)):
+ invoice = self.line.move_origin
+ if self.kind == 'payable':
+ reference = invoice.supplier_payment_reference
+ elif self.kind == 'receivable':
+ reference = invoice.customer_payment_reference
+ return reference
+
+
class ProcessPayment(Wizard):
__name__ = 'account.payment.process'
start_state = 'process'
diff -r c8cc00c41722 -r b8a22af28093 modules/account_payment/tryton.cfg
--- a/modules/account_payment/tryton.cfg Mon Sep 29 15:33:46 2025 +0200
+++ b/modules/account_payment/tryton.cfg Mon Sep 29 15:37:10 2025 +0200
@@ -51,6 +51,7 @@
[register account_invoice]
model:
account.Invoice
+ payment.Payment_Invoice
[register account_statement]
model:
diff -r c8cc00c41722 -r b8a22af28093 modules/account_payment_sepa/payment.py
--- a/modules/account_payment_sepa/payment.py Mon Sep 29 15:33:46 2025 +0200
+++ b/modules/account_payment_sepa/payment.py Mon Sep 29 15:37:10 2025 +0200
@@ -435,10 +435,7 @@
@property
def sepa_remittance_information(self):
- if self.reference:
- return self.reference
- elif self.line and self.line.move_origin:
- return getattr(self.line.move_origin, 'rec_name', '')
+ return self.reference_used
@property
def sepa_bank_account_number(self):