mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] account_payment_order: always return a string in the _get_payment_order_communication
This commit is contained in:
committed by
Kaynnan Lemes
parent
69a91bc23c
commit
d271494155
@@ -43,7 +43,7 @@ class AccountMove(models.Model):
|
||||
"""
|
||||
Retrieve the communication string for the payment order
|
||||
"""
|
||||
communication = self.payment_reference or self.ref or self.name or ""
|
||||
communication = self.payment_reference or self.ref or self.name
|
||||
if self.is_invoice():
|
||||
if (self.reference_type or "none") != "none":
|
||||
communication = self.ref
|
||||
@@ -62,7 +62,7 @@ class AccountMove(models.Model):
|
||||
]
|
||||
)
|
||||
communication += " " + " ".join(references)
|
||||
return communication
|
||||
return communication or ""
|
||||
|
||||
def _prepare_new_payment_order(self, payment_mode=None):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -281,6 +281,28 @@ class TestPaymentOrderOutbound(TestPaymentOrderOutboundBase):
|
||||
self.invoice.payment_reference = "R1234"
|
||||
self.assertEqual("F1242", self.invoice._get_payment_order_communication())
|
||||
|
||||
def test_invoice_communication_03(self):
|
||||
self.invoice.ref = False
|
||||
self.invoice.action_post()
|
||||
self.assertEqual("", self.invoice._get_payment_order_communication())
|
||||
reverse_wizard = Form(
|
||||
self.env["account.move.reversal"].with_context(
|
||||
active_ids=self.invoice.ids, active_model=self.invoice._name
|
||||
)
|
||||
)
|
||||
reverse = reverse_wizard.save()
|
||||
reverse_res = reverse.reverse_moves()
|
||||
reverse_move = self.env[reverse_res["res_model"]].browse(reverse_res["res_id"])
|
||||
self.assertEqual(
|
||||
" %s" % reverse_move.ref,
|
||||
self.invoice._get_payment_order_communication(),
|
||||
)
|
||||
self.invoice.ref = "ref"
|
||||
self.assertEqual(
|
||||
"ref %s" % reverse_move.ref,
|
||||
self.invoice._get_payment_order_communication(),
|
||||
)
|
||||
|
||||
def test_manual_line_and_manual_date(self):
|
||||
# Create payment order
|
||||
outbound_order = self.env["account.payment.order"].create(
|
||||
|
||||
Reference in New Issue
Block a user