Skip to content

Commit

Permalink
Merge PR #1331 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Aug 17, 2024
2 parents 4034b4b + a8319e3 commit c162203
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion account_payment_order/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _get_payment_order_communication_direct(self):
communication = self.payment_reference or self.ref or self.name
if self.is_invoice():
if self.is_purchase_document():
communication = self.ref or self.payment_reference
communication = self.payment_reference or self.ref
else:
communication = self.payment_reference or self.name
return communication or ""
Expand Down
21 changes: 16 additions & 5 deletions account_payment_order/tests/test_payment_order_outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,13 @@ def test_invoice_communication_01(self):
)

def test_invoice_communication_02(self):
self.invoice.payment_reference = "R1234"
self.assertEqual(
"F1242", self.invoice._get_payment_order_communication_direct()
)
self.invoice.payment_reference = "R1234"
self.assertEqual(
"R1234", self.invoice._get_payment_order_communication_direct()
)

def test_invoice_communication_03(self):
self.invoice.ref = False
Expand All @@ -331,6 +334,13 @@ def test_invoice_communication_03(self):
self.invoice._get_payment_order_communication_full(),
)

def test_supplier_invoice_payment_reference(self):
self.invoice.payment_reference = "+++F1234+++"
self.invoice.action_post()
self.assertEqual(
"+++F1234+++", self.invoice._get_payment_order_communication_full()
)

def test_manual_line_and_manual_date(self):
# Create payment order
outbound_order = self.env["account.payment.order"].create(
Expand Down Expand Up @@ -433,7 +443,7 @@ def test_supplier_refund_reference(self):
self.invoice.payment_reference = "F/1234"
self.invoice.action_post()
self.assertEqual(
"F1242", self.invoice._get_payment_order_communication_direct()
"F/1234", self.invoice._get_payment_order_communication_direct()
)
self.refund = self._create_supplier_refund(self.invoice)
with Form(self.refund) as refund_form:
Expand All @@ -443,7 +453,9 @@ def test_supplier_refund_reference(self):
line_form.price_unit = 75.0

self.refund.action_post()
self.assertEqual("R1234", self.refund._get_payment_order_communication_direct())
self.assertEqual(
"FR/1234", self.refund._get_payment_order_communication_direct()
)

# The user add the outstanding payment to the invoice
invoice_line = self.invoice.line_ids.filtered(
Expand All @@ -465,8 +477,7 @@ def test_supplier_refund_reference(self):

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

self.assertEqual("F1242 R1234", payment_order.payment_line_ids.communication)
self.assertNotIn("FR/1234", payment_order.payment_line_ids.communication)
self.assertEqual("F/1234 FR/1234", payment_order.payment_line_ids.communication)

def test_supplier_manual_refund(self):
"""
Expand Down

0 comments on commit c162203

Please sign in to comment.