mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Update test suite
Fix bug in account_banking_mandate when a res.partner.bank is not attached to a particular company (company_id is NOT required on res.partner.bank)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"name": "Account Banking Mandate",
|
||||
"summary": "Banking mandates",
|
||||
"version": "14.0.1.1.0",
|
||||
"version": "14.0.1.1.1",
|
||||
"license": "AGPL-3",
|
||||
"author": "Compassion CH, "
|
||||
"Tecnativa, "
|
||||
|
||||
@@ -20,7 +20,7 @@ class ResPartnerBank(models.Model):
|
||||
@api.constrains("company_id")
|
||||
def _company_constrains(self):
|
||||
for rpb in self:
|
||||
if (
|
||||
if rpb.company_id and (
|
||||
self.env["account.banking.mandate"]
|
||||
.sudo()
|
||||
.search(
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"name": "Account Banking PAIN Base Module",
|
||||
"summary": "Base module for PAIN file generation",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "14.0.1.0.1",
|
||||
"license": "AGPL-3",
|
||||
"author": "Akretion, Noviat, Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/bank-payment",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
"name": "Account Banking SEPA Credit Transfer",
|
||||
"summary": "Create SEPA XML files for Credit Transfers",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "14.0.1.0.1",
|
||||
"license": "AGPL-3",
|
||||
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/bank-payment",
|
||||
|
||||
@@ -10,7 +10,6 @@ from lxml import etree
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests.common import SavepointCase
|
||||
from odoo.tools import float_compare
|
||||
|
||||
|
||||
class TestSCT(SavepointCase):
|
||||
@@ -182,12 +181,11 @@ class TestSCT(SavepointCase):
|
||||
)
|
||||
self.assertEqual(len(pay_lines), 3)
|
||||
agrolait_pay_line1 = pay_lines[0]
|
||||
accpre = self.env["decimal.precision"].precision_get("Account")
|
||||
self.assertEqual(agrolait_pay_line1.currency_id, self.eur_currency)
|
||||
self.assertEqual(agrolait_pay_line1.partner_bank_id, invoice1.partner_bank_id)
|
||||
self.assertEqual(
|
||||
float_compare(
|
||||
agrolait_pay_line1.amount_currency, 42, precision_digits=accpre
|
||||
agrolait_pay_line1.currency_id.compare_amounts(
|
||||
agrolait_pay_line1.amount_currency, 42
|
||||
),
|
||||
0,
|
||||
)
|
||||
@@ -203,8 +201,8 @@ class TestSCT(SavepointCase):
|
||||
agrolait_bank_line = bank_lines[0]
|
||||
self.assertEqual(agrolait_bank_line.currency_id, self.eur_currency)
|
||||
self.assertEqual(
|
||||
float_compare(
|
||||
agrolait_bank_line.amount_currency, 49.0, precision_digits=accpre
|
||||
agrolait_bank_line.currency_id.compare_amounts(
|
||||
agrolait_bank_line.amount_currency, 49.0
|
||||
),
|
||||
0,
|
||||
)
|
||||
@@ -240,7 +238,7 @@ class TestSCT(SavepointCase):
|
||||
for inv in [invoice1, invoice2, invoice3, invoice4, invoice5]:
|
||||
self.assertEqual(inv.state, "posted")
|
||||
self.assertEqual(
|
||||
float_compare(inv.amount_residual, 0.0, precision_digits=accpre),
|
||||
inv.currency_id.compare_amounts(inv.amount_residual, 0.0),
|
||||
0,
|
||||
)
|
||||
return
|
||||
@@ -275,12 +273,11 @@ class TestSCT(SavepointCase):
|
||||
)
|
||||
self.assertEqual(len(pay_lines), 2)
|
||||
asus_pay_line1 = pay_lines[0]
|
||||
accpre = self.env["decimal.precision"].precision_get("Account")
|
||||
self.assertEqual(asus_pay_line1.currency_id, self.usd_currency)
|
||||
self.assertEqual(asus_pay_line1.partner_bank_id, invoice1.partner_bank_id)
|
||||
self.assertEqual(
|
||||
float_compare(
|
||||
asus_pay_line1.amount_currency, 2042, precision_digits=accpre
|
||||
asus_pay_line1.currency_id.compare_amounts(
|
||||
asus_pay_line1.amount_currency, 2042
|
||||
),
|
||||
0,
|
||||
)
|
||||
@@ -296,8 +293,8 @@ class TestSCT(SavepointCase):
|
||||
asus_bank_line = bank_lines[0]
|
||||
self.assertEqual(asus_bank_line.currency_id, self.usd_currency)
|
||||
self.assertEqual(
|
||||
float_compare(
|
||||
asus_bank_line.amount_currency, 3054.0, precision_digits=accpre
|
||||
asus_bank_line.currency_id.compare_amounts(
|
||||
asus_bank_line.amount_currency, 3054.0
|
||||
),
|
||||
0,
|
||||
)
|
||||
@@ -333,7 +330,7 @@ class TestSCT(SavepointCase):
|
||||
for inv in [invoice1, invoice2]:
|
||||
self.assertEqual(inv.state, "posted")
|
||||
self.assertEqual(
|
||||
float_compare(inv.amount_residual, 0.0, precision_digits=accpre),
|
||||
inv.currency_id.compare_amounts(inv.amount_residual, 0.0),
|
||||
0,
|
||||
)
|
||||
return
|
||||
@@ -349,7 +346,7 @@ class TestSCT(SavepointCase):
|
||||
move_type="in_invoice",
|
||||
):
|
||||
partner_bank = cls.env.ref(partner_bank_xmlid)
|
||||
partner_bank.write({"company_id": cls.main_company.id})
|
||||
partner_bank.write({"company_id": False})
|
||||
data = {
|
||||
"partner_id": partner_id,
|
||||
"reference_type": "none",
|
||||
@@ -359,6 +356,7 @@ class TestSCT(SavepointCase):
|
||||
"move_type": move_type,
|
||||
"payment_mode_id": cls.payment_mode.id,
|
||||
"partner_bank_id": partner_bank.id,
|
||||
"company_id": cls.main_company.id,
|
||||
"invoice_line_ids": [],
|
||||
}
|
||||
line_data = {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
"name": "Account Banking SEPA Direct Debit",
|
||||
"summary": "Create SEPA files for Direct Debit",
|
||||
"version": "14.0.1.1.0",
|
||||
"version": "14.0.1.1.1",
|
||||
"license": "AGPL-3",
|
||||
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/bank-payment",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Mode",
|
||||
"version": "14.0.1.0.1",
|
||||
"version": "14.0.1.0.2",
|
||||
"development_status": "Production/Stable",
|
||||
"license": "AGPL-3",
|
||||
"author": "Akretion,Odoo Community Association (OCA)",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# © 2017 Creu Blanca
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
@@ -48,37 +47,6 @@ class TestPaymentMode(TransactionCase):
|
||||
}
|
||||
)
|
||||
|
||||
def test_constrains(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write(
|
||||
{"generate_move": True, "offsetting_account": False}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write(
|
||||
{
|
||||
"generate_move": True,
|
||||
"offsetting_account": "bank_account",
|
||||
"move_option": False,
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write(
|
||||
{
|
||||
"generate_move": True,
|
||||
"offsetting_account": "transfer_account",
|
||||
"transfer_account_id": False,
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write(
|
||||
{
|
||||
"generate_move": True,
|
||||
"offsetting_account": "transfer_account",
|
||||
"transfer_account_id": self.account.id,
|
||||
"transfer_journal_id": False,
|
||||
}
|
||||
)
|
||||
|
||||
def test_onchange_generate_move(self):
|
||||
self.payment_mode_c1.generate_move = True
|
||||
self.payment_mode_c1.generate_move_change()
|
||||
@@ -87,11 +55,6 @@ class TestPaymentMode(TransactionCase):
|
||||
self.payment_mode_c1.generate_move_change()
|
||||
self.assertFalse(self.payment_mode_c1.move_option)
|
||||
|
||||
def test_onchange_offsetting_account(self):
|
||||
self.payment_mode_c1.offsetting_account = "bank_account"
|
||||
self.payment_mode_c1.offsetting_account_change()
|
||||
self.assertFalse(self.payment_mode_c1.transfer_account_id)
|
||||
|
||||
def test_onchange_payment_type(self):
|
||||
self.payment_mode_c1.payment_method_id = self.manual_in
|
||||
self.payment_mode_c1.payment_method_id_change()
|
||||
|
||||
@@ -115,7 +115,7 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase):
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
bank_line.unlink()
|
||||
payment_order.action_done_cancel()
|
||||
payment_order.action_uploaded_cancel()
|
||||
self.assertEqual(payment_order.state, "cancel")
|
||||
payment_order.cancel2draft()
|
||||
payment_order.unlink()
|
||||
|
||||
@@ -48,8 +48,8 @@ class TestPaymentOrderOutbound(AccountTestInvoicingCommon):
|
||||
).id,
|
||||
}
|
||||
)
|
||||
cls.invoice = cls._create_supplier_invoice(cls)
|
||||
cls.invoice_02 = cls._create_supplier_invoice(cls)
|
||||
cls.invoice = cls._create_supplier_invoice(cls, "F1242")
|
||||
cls.invoice_02 = cls._create_supplier_invoice(cls, "F1243")
|
||||
cls.bank_journal = cls.company_data["default_journal_bank"]
|
||||
# Make sure no other payment orders are in the DB
|
||||
cls.domain = [
|
||||
@@ -59,11 +59,12 @@ class TestPaymentOrderOutbound(AccountTestInvoicingCommon):
|
||||
]
|
||||
cls.env["account.payment.order"].search(cls.domain).unlink()
|
||||
|
||||
def _create_supplier_invoice(self):
|
||||
def _create_supplier_invoice(self, ref):
|
||||
invoice = self.env["account.move"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"move_type": "in_invoice",
|
||||
"ref": ref,
|
||||
"payment_mode_id": self.mode.id,
|
||||
"invoice_date": fields.Date.today(),
|
||||
"invoice_line_ids": [
|
||||
@@ -157,8 +158,7 @@ class TestPaymentOrderOutbound(AccountTestInvoicingCommon):
|
||||
order.open2generated()
|
||||
order.generated2uploaded()
|
||||
self.assertEqual(order.move_ids[0].date, order.bank_line_ids[0].date)
|
||||
order.action_done()
|
||||
self.assertEqual(order.state, "done")
|
||||
self.assertEqual(order.state, "uploaded")
|
||||
|
||||
def test_cancel_payment_order(self):
|
||||
# Open invoice
|
||||
@@ -193,7 +193,7 @@ class TestPaymentOrderOutbound(AccountTestInvoicingCommon):
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
bank_line.unlink()
|
||||
payment_order.action_done_cancel()
|
||||
payment_order.action_uploaded_cancel()
|
||||
self.assertEqual(payment_order.state, "cancel")
|
||||
payment_order.cancel2draft()
|
||||
payment_order.unlink()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Partner",
|
||||
"version": "14.0.1.3.1",
|
||||
"version": "14.0.1.3.2",
|
||||
"category": "Banking addons",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Adds payment mode on partners and invoices",
|
||||
|
||||
Reference in New Issue
Block a user