Skip to content

Commit

Permalink
[REF] l10n_ch_pain_credit_transfer: Black python code
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn authored and ecino committed Dec 7, 2023
1 parent a52f038 commit b8a84c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# copyright 2016 Akretion (Alexis de Lattre <[email protected]>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
from odoo import fields, models


class AccountPaymentMethod(models.Model):
Expand Down
58 changes: 22 additions & 36 deletions l10n_ch_pain_credit_transfer/tests/test_ch_sct.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ def setUp(self):
)
# create a ch bank account for my company
self.cp_partner_bank = self.partner_bank_model.create(
{
"acc_number": ch_iban,
"partner_id": self.env.ref("base.main_partner").id,
}
{"acc_number": ch_iban, "partner_id": self.env.ref("base.main_partner").id}
)
self.cp_partner_bank._onchange_acc_number_set_swiss_bank()
# create journal
Expand All @@ -87,9 +84,7 @@ def setUp(self):
"payment_method_id": pay_method_id,
}
)
self.payment_mode.payment_method_id.pain_version = (
"pain.001.001.03.ch.02"
)
self.payment_mode.payment_method_id.pain_version = "pain.001.001.03.ch.02"
self.chf_currency = self.env.ref("base.CHF")
self.eur_currency = self.env.ref("base.EUR")
ch_bank2 = self.env["res.bank"].create(
Expand Down Expand Up @@ -129,9 +124,7 @@ def test_sct_ch_payment_type1(self):
self.assertEquals(action["res_model"], "account.payment.order")
self.payment_order = self.payment_order_model.browse(action["res_id"])
self.assertEquals(self.payment_order.payment_type, "outbound")
self.assertEquals(
self.payment_order.payment_mode_id, self.payment_mode
)
self.assertEquals(self.payment_order.payment_mode_id, self.payment_mode)
self.assertEquals(self.payment_order.journal_id, self.bank_journal)
pay_lines = self.payment_line_model.search(
[
Expand Down Expand Up @@ -168,10 +161,7 @@ def test_sct_ch_payment_type1(self):
self.assertEquals(bank_line.communication_type, "isr")
self.assertTrue(
bank_line.communication
in [
"132000000000000000000000014",
"132000000000000000000000022",
]
in ["132000000000000000000000014", "132000000000000000000000022"]
)
self.assertEquals(
bank_line.partner_bank_id, invoice1.invoice_partner_bank_id
Expand All @@ -188,13 +178,10 @@ def test_sct_ch_payment_type1(self):
namespaces = xml_root.nsmap
namespaces["p"] = xml_root.nsmap[None]
namespaces.pop(None)
pay_method_xpath = xml_root.xpath(
"//p:PmtInf/p:PmtMtd", namespaces=namespaces
)
pay_method_xpath = xml_root.xpath("//p:PmtInf/p:PmtMtd", namespaces=namespaces)
self.assertEquals(
namespaces["p"],
"http://www.six-interbank-clearing.com/de/"
"pain.001.001.03.ch.02.xsd",
"http://www.six-interbank-clearing.com/de/" "pain.001.001.03.ch.02.xsd",
)
self.assertEquals(pay_method_xpath[0].text, "TRF")
sepa_xpath = xml_root.xpath(
Expand Down Expand Up @@ -239,9 +226,7 @@ def test_sct_ch_payment_type3(self):
self.assertEquals(action["res_model"], "account.payment.order")
self.payment_order = self.payment_order_model.browse(action["res_id"])
self.assertEquals(self.payment_order.payment_type, "outbound")
self.assertEquals(
self.payment_order.payment_mode_id, self.payment_mode
)
self.assertEquals(self.payment_order.payment_mode_id, self.payment_mode)
self.assertEquals(self.payment_order.journal_id, self.bank_journal)
pay_lines = self.payment_line_model.search(
[
Expand All @@ -258,9 +243,7 @@ def test_sct_ch_payment_type3(self):
)
self.assertEquals(
float_compare(
agrolait_pay_line1.amount_currency,
4042.0,
precision_digits=accpre,
agrolait_pay_line1.amount_currency, 4042.0, precision_digits=accpre,
),
0,
)
Expand Down Expand Up @@ -290,13 +273,10 @@ def test_sct_ch_payment_type3(self):
namespaces = xml_root.nsmap
namespaces["p"] = xml_root.nsmap[None]
namespaces.pop(None)
pay_method_xpath = xml_root.xpath(
"//p:PmtInf/p:PmtMtd", namespaces=namespaces
)
pay_method_xpath = xml_root.xpath("//p:PmtInf/p:PmtMtd", namespaces=namespaces)
self.assertEquals(
namespaces["p"],
"http://www.six-interbank-clearing.com/de/"
"pain.001.001.03.ch.02.xsd",
"http://www.six-interbank-clearing.com/de/" "pain.001.001.03.ch.02.xsd",
)
self.assertEquals(pay_method_xpath[0].text, "TRF")
sepa_xpath = xml_root.xpath(
Expand Down Expand Up @@ -339,12 +319,18 @@ def create_invoice(
"name": "/",
"payment_mode_id": self.payment_mode.id,
"invoice_partner_bank_id": partner_bank_id,
"invoice_line_ids": [(0, 0, {
"price_unit": price_unit,
"quantity": 1,
"name": "Great service",
"account_id": self.account_expense.id,
})],
"invoice_line_ids": [
(
0,
0,
{
"price_unit": price_unit,
"quantity": 1,
"name": "Great service",
"account_id": self.account_expense.id,
},
)
],
}
)
invoice.action_post()
Expand Down

0 comments on commit b8a84c0

Please sign in to comment.