Skip to content

Commit

Permalink
[FIX] account_payment_order: Always return a string in the _get_payme…
Browse files Browse the repository at this point in the history
…nt_order_order_communication_direct() method.

Related to: #1178
  • Loading branch information
victoralmau authored and ramiadavid committed Jan 13, 2024
1 parent 42f9272 commit 1fd87cf
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 22 deletions.
2 changes: 1 addition & 1 deletion account_payment_order/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion account_payment_order/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down
4 changes: 2 additions & 2 deletions account_payment_order/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def _compute_payment_line_count(self):

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
elif self.is_purchase_document():
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.
Expand Down
2 changes: 1 addition & 1 deletion account_payment_order/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Account Payment Order</h1>
!! 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>
Expand Down
3 changes: 2 additions & 1 deletion account_payment_order/tests/test_account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

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")
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
)
Expand Down
34 changes: 18 additions & 16 deletions account_payment_order/tests/test_payment_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
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
)
Expand All @@ -24,47 +26,47 @@ def _get_payment_method_information(self):
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,
"_get_payment_method_information",
_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",
"payment_type": "outbound",
}
)

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])],
}
)

Expand Down
2 changes: 2 additions & 0 deletions account_payment_order/tests/test_payment_order_inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
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")
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(
Expand Down
24 changes: 24 additions & 0 deletions account_payment_order/tests/test_payment_order_outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
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")
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(
Expand Down Expand Up @@ -276,6 +278,28 @@ def test_invoice_communication_02(self):
"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(
Expand Down

0 comments on commit 1fd87cf

Please sign in to comment.