Merge PR #1284 into 14.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2024-06-07 08:44:29 +00:00
2 changed files with 24 additions and 2 deletions

View File

@@ -43,7 +43,7 @@ class AccountMove(models.Model):
""" """
Retrieve the communication string for the payment order 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.is_invoice():
if (self.reference_type or "none") != "none": if (self.reference_type or "none") != "none":
communication = self.ref communication = self.ref
@@ -62,7 +62,7 @@ class AccountMove(models.Model):
] ]
) )
communication += " " + " ".join(references) communication += " " + " ".join(references)
return communication return communication or ""
def _prepare_new_payment_order(self, payment_mode=None): def _prepare_new_payment_order(self, payment_mode=None):
self.ensure_one() self.ensure_one()

View File

@@ -281,6 +281,28 @@ class TestPaymentOrderOutbound(TestPaymentOrderOutboundBase):
self.invoice.payment_reference = "R1234" self.invoice.payment_reference = "R1234"
self.assertEqual("F1242", self.invoice._get_payment_order_communication()) 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): def test_manual_line_and_manual_date(self):
# Create payment order # Create payment order
outbound_order = self.env["account.payment.order"].create( outbound_order = self.env["account.payment.order"].create(