From da569b2135f9347205287af2ccec7996ee426bc3 Mon Sep 17 00:00:00 2001 From: manu Date: Fri, 8 Apr 2022 16:57:13 +0200 Subject: [PATCH] [MIG]account_banking_sepa_credit_transfer: Migration to 15.0 --- .../__manifest__.py | 2 +- .../models/account_payment_method.py | 11 ++++++++++- .../models/account_payment_order.py | 6 +++--- .../post_install.py | 12 +++++++++++- .../readme/CONTRIBUTORS.rst | 1 + .../tests/test_sct.py | 17 +++++++++++++++-- 6 files changed, 41 insertions(+), 8 deletions(-) diff --git a/account_banking_sepa_credit_transfer/__manifest__.py b/account_banking_sepa_credit_transfer/__manifest__.py index d4f86de52..9b274bd84 100644 --- a/account_banking_sepa_credit_transfer/__manifest__.py +++ b/account_banking_sepa_credit_transfer/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Account Banking SEPA Credit Transfer", "summary": "Create SEPA XML files for Credit Transfers", - "version": "14.0.1.2.0", + "version": "15.0.1.0.0", "license": "AGPL-3", "author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-payment", 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 c8ac49d13..96669557b 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 @@ class AccountPaymentMethod(models.Model): ) 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/models/account_payment_order.py b/account_banking_sepa_credit_transfer/models/account_payment_order.py index 72e226d9b..f2f92d38a 100644 --- a/account_banking_sepa_credit_transfer/models/account_payment_order.py +++ b/account_banking_sepa_credit_transfer/models/account_payment_order.py @@ -178,10 +178,10 @@ class AccountPaymentOrder(models.Model): raise UserError( _( "Bank account is missing on the bank payment line " - "of partner '%s' (reference '%s')." - ) - % (line.partner_id.name, line.name) + "of partner '{partner}' (reference '{reference}')." + ).format(partner=line.partner_id.name, reference=line.name) ) + self.generate_party_block( credit_transfer_transaction_info, "Cdtr", diff --git a/account_banking_sepa_credit_transfer/post_install.py b/account_banking_sepa_credit_transfer/post_install.py index 8137da55a..8cfd84b8f 100644 --- a/account_banking_sepa_credit_transfer/post_install.py +++ b/account_banking_sepa_credit_transfer/post_install.py @@ -11,5 +11,15 @@ def update_bank_journals(cr, registry): 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)]}) + journals.write( + { + "outbound_payment_method_line_ids": [ + ( + 0, + 0, + {"payment_method_id": sct.id, "name": "SEPA Direct Credit"}, + ) + ] + } + ) return diff --git a/account_banking_sepa_credit_transfer/readme/CONTRIBUTORS.rst b/account_banking_sepa_credit_transfer/readme/CONTRIBUTORS.rst index 7406b936d..a9b2a4bf6 100644 --- a/account_banking_sepa_credit_transfer/readme/CONTRIBUTORS.rst +++ b/account_banking_sepa_credit_transfer/readme/CONTRIBUTORS.rst @@ -17,3 +17,4 @@ * `Sygel Technology `_: * Valentin Vinagre + * Manuel Regidor diff --git a/account_banking_sepa_credit_transfer/tests/test_sct.py b/account_banking_sepa_credit_transfer/tests/test_sct.py index 7593716d9..933323e61 100644 --- a/account_banking_sepa_credit_transfer/tests/test_sct.py +++ b/account_banking_sepa_credit_transfer/tests/test_sct.py @@ -9,10 +9,10 @@ import time from lxml import etree from odoo.exceptions import UserError -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestSCT(SavepointCase): +class TestSCT(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -96,8 +96,21 @@ class TestSCT(SavepointCase): "bank_account_id": cls.partner_bank.id, "bank_id": cls.partner_bank.bank_id.id, "company_id": cls.main_company.id, + "outbound_payment_method_line_ids": [ + ( + 0, + 0, + { + "payment_method_id": cls.env.ref( + "account_banking_sepa_credit_transfer.sepa_credit_transfer" + ).id, + "payment_account_id": cls.account_payable.id, + }, + ) + ], } ) + # update payment mode cls.payment_mode = cls.env.ref( "account_banking_sepa_credit_transfer.payment_mode_outbound_sepa_ct1"