Skip to content

Commit eb5bcb9

Browse files
committed
[FIX] account_payment_order: use payment_reference if available for out payments
1 parent c667a24 commit eb5bcb9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

account_payment_order/models/account_move.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _get_payment_order_communication_direct(self):
5353
communication = self.payment_reference or self.ref or self.name
5454
if self.is_invoice():
5555
if self.is_purchase_document():
56-
communication = self.ref or self.payment_reference
56+
communication = self.payment_reference or self.ref or ""
5757
else:
5858
communication = self.payment_reference or self.name
5959
return communication or ""

account_payment_order/tests/test_payment_order_outbound.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,14 @@ def test_invoice_communication_01(self):
307307
def test_invoice_communication_02(self):
308308
self.invoice.payment_reference = "R1234"
309309
self.assertEqual(
310-
"F1242", self.invoice._get_payment_order_communication_direct()
310+
"R1234", self.invoice._get_payment_order_communication_direct()
311+
)
312+
313+
def test_supplier_invoice_payment_reference(self):
314+
self.invoice.payment_reference = "+++F1234+++"
315+
self.invoice.action_post()
316+
self.assertEqual(
317+
"+++F1234+++", self.invoice._get_payment_order_communication_full()
311318
)
312319

313320
@mute_logger("odoo.models.unlink")
@@ -437,7 +444,7 @@ def test_supplier_refund_reference(self):
437444
self.invoice.payment_reference = "F/1234"
438445
self.invoice.action_post()
439446
self.assertEqual(
440-
"F1242", self.invoice._get_payment_order_communication_direct()
447+
"F/1234", self.invoice._get_payment_order_communication_direct()
441448
)
442449
self.refund = self._create_supplier_refund(self.invoice)
443450
with Form(self.refund) as refund_form:
@@ -447,7 +454,9 @@ def test_supplier_refund_reference(self):
447454
line_form.price_unit = 75.0
448455

449456
self.refund.action_post()
450-
self.assertEqual("R1234", self.refund._get_payment_order_communication_direct())
457+
self.assertEqual(
458+
"FR/1234", self.refund._get_payment_order_communication_direct()
459+
)
451460

452461
self.env["account.invoice.payment.line.multi"].with_context(
453462
active_model="account.move", active_ids=self.invoice.ids
@@ -460,8 +469,7 @@ def test_supplier_refund_reference(self):
460469

461470
self.assertEqual(len(payment_order.payment_line_ids), 1)
462471

463-
self.assertEqual("F1242 R1234", payment_order.payment_line_ids.communication)
464-
self.assertNotIn("FR/1234", payment_order.payment_line_ids.communication)
472+
self.assertEqual("F/1234 FR/1234", payment_order.payment_line_ids.communication)
465473

466474
def test_supplier_manual_refund(self):
467475
"""

0 commit comments

Comments
 (0)