diff --git a/account_banking_sepa_credit_transfer/__init__.py b/account_banking_sepa_credit_transfer/__init__.py index e2b93a53566..0650744f6bc 100644 --- a/account_banking_sepa_credit_transfer/__init__.py +++ b/account_banking_sepa_credit_transfer/__init__.py @@ -1,2 +1 @@ from . import models -from .post_install import update_bank_journals diff --git a/account_banking_sepa_credit_transfer/__manifest__.py b/account_banking_sepa_credit_transfer/__manifest__.py index 9a7d9d8e4fe..9db14fd6817 100644 --- a/account_banking_sepa_credit_transfer/__manifest__.py +++ b/account_banking_sepa_credit_transfer/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Account Banking SEPA Credit Transfer", "summary": "Create SEPA XML files for Credit Transfers", - "version": "14.0.2.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "Akretion, Tecnativa, Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-payment", @@ -15,6 +15,5 @@ "depends": ["account_banking_pain_base"], "data": ["data/account_payment_method.xml"], "demo": ["demo/sepa_credit_transfer_demo.xml"], - "post_init_hook": "update_bank_journals", "installable": True, } diff --git a/account_banking_sepa_credit_transfer/models/account_payment_method.py b/account_banking_sepa_credit_transfer/models/account_payment_method.py index e4dc113774f..a962b014bdf 100644 --- a/account_banking_sepa_credit_transfer/models/account_payment_method.py +++ b/account_banking_sepa_credit_transfer/models/account_payment_method.py @@ -1,7 +1,7 @@ # Copyright 2016-2020 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class AccountPaymentMethod(models.Model): @@ -38,3 +38,12 @@ def get_xsd_file_path(self): ) return path return super().get_xsd_file_path() + + @api.model + def _get_payment_method_information(self): + res = super()._get_payment_method_information() + res["sepa_credit_transfer"] = { + "mode": "multi", + "domain": [("type", "=", "bank")], + } + return res diff --git a/account_banking_sepa_credit_transfer/post_install.py b/account_banking_sepa_credit_transfer/post_install.py deleted file mode 100644 index 8137da55ace..00000000000 --- a/account_banking_sepa_credit_transfer/post_install.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2016-2020 Akretion (Alexis de Lattre ) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from odoo import SUPERUSER_ID, api - - -def update_bank_journals(cr, registry): - with api.Environment.manage(): - env = api.Environment(cr, SUPERUSER_ID, {}) - ajo = env["account.journal"] - journals = ajo.search([("type", "=", "bank")]) - sct = env.ref("account_banking_sepa_credit_transfer.sepa_credit_transfer") - if sct: - journals.write({"outbound_payment_method_ids": [(4, sct.id)]}) - return diff --git a/account_banking_sepa_credit_transfer/tests/test_sct.py b/account_banking_sepa_credit_transfer/tests/test_sct.py index 8434ab498ff..b4ee1b9fdea 100644 --- a/account_banking_sepa_credit_transfer/tests/test_sct.py +++ b/account_banking_sepa_credit_transfer/tests/test_sct.py @@ -8,11 +8,12 @@ from lxml import etree -from odoo.exceptions import UserError -from odoo.tests.common import SavepointCase +from odoo import _ +from odoo.exceptions import UserError, ValidationError +from odoo.tests.common import TransactionCase -class TestSCT(SavepointCase): +class TestSCT(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -30,9 +31,7 @@ def setUpClass(cls): cls.partner_c2c = cls.env.ref("base.res_partner_12") cls.eur_currency = cls.env.ref("base.EUR") cls.usd_currency = cls.env.ref("base.USD") - cls.main_company = cls.env["res.company"].create( - {"name": "Test EUR company", "currency_id": cls.eur_currency.id} - ) + cls.main_company = cls.env["res.company"].create({"name": "Test EUR company"}) cls.partner_agrolait.company_id = cls.main_company.id cls.partner_asus.company_id = cls.main_company.id cls.partner_c2c.company_id = cls.main_company.id @@ -42,21 +41,28 @@ def setUpClass(cls): "company_id": cls.main_company.id, } ) + + charts = cls.env["account.chart.template"].search([]) + if charts: + cls.chart = charts[0] + else: + raise ValidationError(_("No Chart of Account Template has been defined !")) + cls.chart.try_loading() + cls.account_expense = cls.account_model.create( { - "user_type_id": cls.env.ref("account.data_account_type_expenses").id, - "name": "Test expense account", - "code": "TEA", + "account_type": "expense", "company_id": cls.main_company.id, + "name": "Test expense", + "code": "TE.1", } ) cls.account_payable = cls.account_model.create( { - "user_type_id": cls.env.ref("account.data_account_type_payable").id, - "name": "Test payable account", - "code": "TTA", + "account_type": "liability_payable", "company_id": cls.main_company.id, - "reconcile": True, + "name": "Test payable", + "code": "TP.1", } ) (cls.partner_asus + cls.partner_c2c + cls.partner_agrolait).with_company( @@ -107,6 +113,11 @@ def setUpClass(cls): # Trigger the recompute of account type on res.partner.bank cls.partner_bank_model.search([])._compute_acc_type() + # cls.main_company.write({ + # 'account_journal_payment_debit_account_id': cls.payment_debit_account_id.id, + # 'account_journal_payment_credit_account_id': cls.payment_credit_account_id.id + # }) + def test_no_pain(self): self.payment_mode.payment_method_id.pain_version = False with self.assertRaises(UserError): @@ -353,6 +364,7 @@ def create_invoice( "account_id": cls.account_expense.id, "price_unit": price_unit, "quantity": 1, + "tax_ids": [], # no tax } data["invoice_line_ids"].append((0, 0, line_data)) inv = cls.env["account.move"].create(data)