Skip to content

Commit

Permalink
[MIG] contract_mandate: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aiendry-aktivsoftware committed Sep 1, 2022
1 parent 1144613 commit 437da0f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion contract_mandate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Contract Mandate",
"summary": "Mandate in contracts and their invoices",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"author": "Odoo Community Association (OCA), " "Tecnativa",
"website": "https://github.com/OCA/contract",
"depends": ["contract_payment_mode", "account_banking_mandate"],
Expand Down
46 changes: 39 additions & 7 deletions contract_mandate/tests/test_contract_mandate.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# Copyright 2017 Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from unittest.mock import patch

from odoo.addons.account.models.account_payment_method import AccountPaymentMethod
from odoo.addons.contract.tests.test_contract import TestContractBase


class TestContractMandate(TestContractBase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.payment_method = cls.env["account.payment.method"].create(
{
"name": "Test SDD",
"code": "test_code_sdd",
"payment_type": "inbound",
"mandate_required": True,
}
Method_get_payment_method_information = (
AccountPaymentMethod._get_payment_method_information
)

def _get_payment_method_information(self):
res = Method_get_payment_method_information(self)
res["test_code_sdd"] = {"mode": "multi", "domain": [("type", "=", "bank")]}
return res

with patch.object(
AccountPaymentMethod,
"_get_payment_method_information",
_get_payment_method_information,
):
cls.payment_method = cls.env["account.payment.method"].create(
{
"name": "Test SDD",
"code": "test_code_sdd",
"payment_type": "inbound",
"mandate_required": True,
}
)
cls.payment_mode = cls.env["account.payment.mode"].create(
{
"name": "Test payment mode",
Expand All @@ -26,6 +42,7 @@ def setUpClass(cls):
cls.partner = cls.env["res.partner"].create(
{"name": "Test Customer", "customer_payment_mode_id": cls.payment_mode.id}
)
cls.company = cls.env["res.company"].create({"name": "Test Company"})
cls.partner_bank = cls.env["res.partner.bank"].create(
{"acc_number": "1234", "partner_id": cls.partner.id}
)
Expand All @@ -36,6 +53,15 @@ def setUpClass(cls):
"signature_date": "2017-01-01",
}
)
cls.contract = cls.env["contract.contract"].create(
{
"name": "Test contract",
"partner_id": cls.partner.id,
"company_id": cls.company.id,
"mandate_id": cls.mandate.id,
"mandate_required": False,
}
)
cls.contract_with_mandate = cls.contract2.copy(
{
"partner_id": cls.partner.id,
Expand All @@ -61,3 +87,9 @@ def test_contract_mandate_default(self):
self.contract_with_mandate.mandate_id = False
new_invoice = self.contract_with_mandate.recurring_create_invoice()
self.assertFalse(new_invoice.mandate_id)

def test_onchange_payment_mode_id(self):
self.contract._onchange_partner_id()
self.assertFalse(
self.contract.mandate_required,
)

0 comments on commit 437da0f

Please sign in to comment.