[FIX] account_payment_order: Always return a string in the _get_payment_order_order_communication_direct() method.

Related to: https://github.com/OCA/bank-payment/issues/1178
This commit is contained in:
Víctor Martínez
2023-11-27 09:21:04 +01:00
committed by David Ramia
parent dc03f1070c
commit d882d8e690
8 changed files with 51 additions and 22 deletions

View File

@@ -7,7 +7,7 @@ Account Payment Order
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:27a37f42dfe71cb996e2ff53d039ebc2682b60c582aabe1a7e76aac25ddf3679
!! source digest: sha256:0399e2f98f07d9c21c128885229a0263686b56ece85f6c3fdf4f2a61445b62fe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png

View File

@@ -9,7 +9,7 @@
{
"name": "Account Payment Order",
"version": "16.0.1.6.0",
"version": "16.0.1.6.1",
"license": "AGPL-3",
"author": "ACSONE SA/NV, "
"Therp BV, "

View File

@@ -49,7 +49,7 @@ class AccountMove(models.Model):
def _get_payment_order_communication_direct(self):
"""Retrieve the communication string for this direct item."""
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
@@ -57,7 +57,7 @@ class AccountMove(models.Model):
communication = self.ref or self.payment_reference
else:
communication = self.payment_reference or self.name
return communication
return communication or ""
def _get_payment_order_communication_full(self):
"""Retrieve the full communication string for the payment order.

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:27a37f42dfe71cb996e2ff53d039ebc2682b60c582aabe1a7e76aac25ddf3679
!! source digest: sha256:0399e2f98f07d9c21c128885229a0263686b56ece85f6c3fdf4f2a61445b62fe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/bank-payment/tree/16.0/account_payment_order"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/bank-payment-16-0/bank-payment-16-0-account_payment_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds support for payment orders and debit orders.</p>

View File

@@ -7,6 +7,7 @@ from odoo.tests import tagged
from odoo.addons.account.models.account_payment_method import AccountPaymentMethod
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
@tagged("-at_install", "post_install")
@@ -14,7 +15,7 @@ class TestAccountPayment(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
Method_get_payment_method_information = (
AccountPaymentMethod._get_payment_method_information
)

View File

@@ -6,12 +6,14 @@ from unittest.mock import patch
from odoo.tests.common import TransactionCase
from odoo.addons.account.models.account_payment_method import AccountPaymentMethod
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
class TestPaymentMode(TransactionCase):
def setUp(self):
super(TestPaymentMode, self).setUp()
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
Method_get_payment_method_information = (
AccountPaymentMethod._get_payment_method_information
)
@@ -24,24 +26,24 @@ class TestPaymentMode(TransactionCase):
return res
# Company
self.company = self.env.ref("base.main_company")
cls.company = cls.env.ref("base.main_company")
self.journal_c1 = self.env["account.journal"].create(
cls.journal_c1 = cls.env["account.journal"].create(
{
"name": "Journal 1",
"code": "J1",
"type": "bank",
"company_id": self.company.id,
"company_id": cls.company.id,
}
)
self.account = self.env["account.account"].search(
[("reconcile", "=", True), ("company_id", "=", self.company.id)], limit=1
cls.account = cls.env["account.account"].search(
[("reconcile", "=", True), ("company_id", "=", cls.company.id)], limit=1
)
self.manual_out = self.env.ref("account.account_payment_method_manual_out")
cls.manual_out = cls.env.ref("account.account_payment_method_manual_out")
self.manual_in = self.env.ref("account.account_payment_method_manual_in")
cls.manual_in = cls.env.ref("account.account_payment_method_manual_in")
with patch.object(
AccountPaymentMethod,
@@ -49,7 +51,7 @@ class TestPaymentMode(TransactionCase):
_get_payment_method_information,
):
self.electronic_out = self.env["account.payment.method"].create(
cls.electronic_out = cls.env["account.payment.method"].create(
{
"name": "Electronic Out",
"code": "electronic_out",
@@ -57,14 +59,14 @@ class TestPaymentMode(TransactionCase):
}
)
self.payment_mode_c1 = self.env["account.payment.mode"].create(
cls.payment_mode_c1 = cls.env["account.payment.mode"].create(
{
"name": "Direct Debit of suppliers from Bank 1",
"bank_account_link": "variable",
"payment_method_id": self.manual_out.id,
"company_id": self.company.id,
"fixed_journal_id": self.journal_c1.id,
"variable_journal_ids": [(6, 0, [self.journal_c1.id])],
"payment_method_id": cls.manual_out.id,
"company_id": cls.company.id,
"fixed_journal_id": cls.journal_c1.id,
"variable_journal_ids": [(6, 0, [cls.journal_c1.id])],
}
)

View File

@@ -10,6 +10,7 @@ from odoo.tests import tagged
from odoo.tests.common import Form
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
@tagged("-at_install", "post_install")
@@ -17,6 +18,7 @@ class TestPaymentOrderInboundBase(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.company = cls.company_data["company"]
cls.env.user.company_id = cls.company.id
cls.partner = cls.env["res.partner"].create(

View File

@@ -10,6 +10,7 @@ from odoo.exceptions import UserError, ValidationError
from odoo.tests import Form, tagged
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
@tagged("-at_install", "post_install")
@@ -17,6 +18,7 @@ class TestPaymentOrderOutboundBase(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.company = cls.company_data["company"]
cls.env.user.company_id = cls.company.id
cls.partner = cls.env["res.partner"].create(
@@ -276,6 +278,28 @@ class TestPaymentOrderOutbound(TestPaymentOrderOutboundBase):
"F1242", self.invoice._get_payment_order_communication_direct()
)
def test_invoice_communication_03(self):
self.invoice.ref = False
self.invoice.action_post()
self.assertEqual("", self.invoice._get_payment_order_communication_direct())
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_full(),
)
self.invoice.ref = "ref"
self.assertEqual(
"ref %s" % reverse_move.ref,
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(