diff --git a/account_banking_sepa_direct_debit/__manifest__.py b/account_banking_sepa_direct_debit/__manifest__.py index 93758e4aa..20480430b 100644 --- a/account_banking_sepa_direct_debit/__manifest__.py +++ b/account_banking_sepa_direct_debit/__manifest__.py @@ -5,12 +5,22 @@ { "name": "Account Banking SEPA Direct Debit", "summary": "Create SEPA files for Direct Debit", - "version": "14.0.1.3.1", + "version": "15.0.1.0.0", "license": "AGPL-3", "author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-payment", "category": "Banking addons", "depends": ["account_banking_pain_base", "account_banking_mandate"], + "external_dependencies": { + "python": [ + "stdnum", + ], + }, + "assets": { + "web.assets_backend": [ + "/account_banking_sepa_direct_debit/static/src/css/report.css" + ], + }, "data": [ "views/account_banking_mandate_view.xml", "views/res_config_settings.xml", diff --git a/account_banking_sepa_direct_debit/demo/sepa_direct_debit_demo.xml b/account_banking_sepa_direct_debit/demo/sepa_direct_debit_demo.xml index c22f68416..ec5469e0f 100644 --- a/account_banking_sepa_direct_debit/demo/sepa_direct_debit_demo.xml +++ b/account_banking_sepa_direct_debit/demo/sepa_direct_debit_demo.xml @@ -1,51 +1,37 @@ - - - - SEPA Direct Debit of customers - - variable - - - - - FR78ZZZ424242 - - - - - sepa - recurrent - first - - valid - - - - - - - - sepa - recurrent - first - - valid - - - - - + + + SEPA Direct Debit of customers + + variable + + + + + FR78ZZZ424242 + + + + + sepa + recurrent + first + + valid + + + + + + + + sepa + recurrent + first + + valid + + + + diff --git a/account_banking_sepa_direct_debit/models/account_banking_mandate.py b/account_banking_sepa_direct_debit/models/account_banking_mandate.py index 6b98c7624..9c6ed42b6 100644 --- a/account_banking_sepa_direct_debit/models/account_banking_mandate.py +++ b/account_banking_sepa_direct_debit/models/account_banking_mandate.py @@ -6,7 +6,8 @@ from datetime import datetime from dateutil.relativedelta import relativedelta -from odoo import _, api, exceptions, fields, models +from odoo import _, api, fields, models +from odoo.exceptions import UserError NUMBER_OF_UNUSED_MONTHS_BEFORE_EXPIRY = 36 @@ -39,7 +40,6 @@ class AccountBankingMandate(models.Model): ) scheme = fields.Selection( [("CORE", "Basic (CORE)"), ("B2B", "Enterprise (B2B)")], - string="Scheme", default="CORE", tracking=80, ) @@ -50,7 +50,7 @@ class AccountBankingMandate(models.Model): def _check_recurring_type(self): for mandate in self: if mandate.type == "recurrent" and not mandate.recurrent_sequence_type: - raise exceptions.Warning( + raise UserError( _("The recurrent mandate '%s' must have a sequence type.") % mandate.unique_mandate_reference ) diff --git a/account_banking_sepa_direct_debit/models/account_payment_method.py b/account_banking_sepa_direct_debit/models/account_payment_method.py index ab048504a..0663e9904 100644 --- a/account_banking_sepa_direct_debit/models/account_payment_method.py +++ b/account_banking_sepa_direct_debit/models/account_payment_method.py @@ -1,7 +1,7 @@ # Copyright 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): @@ -33,3 +33,9 @@ class AccountPaymentMethod(models.Model): path = "account_banking_sepa_direct_debit/data/%s.xsd" % self.pain_version return path return super().get_xsd_file_path() + + @api.model + def _get_payment_method_information(self): + res = super()._get_payment_method_information() + res["sepa_direct_debit"] = {"mode": "multi", "domain": [("type", "=", "bank")]} + return res diff --git a/account_banking_sepa_direct_debit/models/account_payment_order.py b/account_banking_sepa_direct_debit/models/account_payment_order.py index 0e0704202..f5a041c49 100644 --- a/account_banking_sepa_direct_debit/models/account_payment_order.py +++ b/account_banking_sepa_direct_debit/models/account_payment_order.py @@ -302,8 +302,7 @@ class AccountPaymentOrder(models.Model): "Automatically switched from First to " "Recurring when the debit order " "%s has been marked as uploaded." - ) - % (order.id, order.name) + "data-oe-id=%d>{} has been marked as uploaded." + ).format(order.id, order.name) ) return res diff --git a/account_banking_sepa_direct_debit/post_install.py b/account_banking_sepa_direct_debit/post_install.py index c6de61867..88b84dad9 100644 --- a/account_banking_sepa_direct_debit/post_install.py +++ b/account_banking_sepa_direct_debit/post_install.py @@ -11,5 +11,15 @@ def update_bank_journals(cr, registry): journals = ajo.search([("type", "=", "bank")]) sdd = env.ref("account_banking_sepa_direct_debit.sepa_direct_debit") if sdd: - journals.write({"inbound_payment_method_ids": [(4, sdd.id)]}) + journals.write( + { + "inbound_payment_method_line_ids": [ + ( + 0, + 0, + {"payment_method_id": sdd.id, "name": "SEPA Direct Debit"}, + ) + ] + } + ) return diff --git a/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst b/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst index 04a019eaa..a69a2bd73 100644 --- a/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst +++ b/account_banking_sepa_direct_debit/readme/CONTRIBUTORS.rst @@ -10,3 +10,4 @@ * Pedro M. Baeza * Sergio Teruel * Carlos Roca +* Manuel Regidor diff --git a/account_banking_sepa_direct_debit/reports/sepa_direct_debit_mandate.xml b/account_banking_sepa_direct_debit/reports/sepa_direct_debit_mandate.xml index 4c37790a7..99cd63a9e 100644 --- a/account_banking_sepa_direct_debit/reports/sepa_direct_debit_mandate.xml +++ b/account_banking_sepa_direct_debit/reports/sepa_direct_debit_mandate.xml @@ -1,17 +1,5 @@ - SEPA Mandate diff --git a/account_banking_sepa_direct_debit/tests/test_sdd.py b/account_banking_sepa_direct_debit/tests/test_sdd.py index 3800cd9cd..dc9d8575c 100644 --- a/account_banking_sepa_direct_debit/tests/test_sdd.py +++ b/account_banking_sepa_direct_debit/tests/test_sdd.py @@ -7,11 +7,11 @@ import base64 from lxml import etree from odoo import fields -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase from odoo.tools import float_compare -class TestSDDBase(SavepointCase): +class TestSDDBase(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -89,6 +89,18 @@ class TestSDDBase(SavepointCase): "code": "BNKFC", "bank_account_id": cls.company_bank.id, "bank_id": cls.company_bank.bank_id.id, + "inbound_payment_method_line_ids": [ + ( + 0, + 0, + { + "payment_method_id": cls.env.ref( + "account_banking_sepa_direct_debit.sepa_direct_debit" + ).id, + "payment_account_id": cls.account_expense_company_B.id, + }, + ) + ], } ) # update payment mode @@ -194,8 +206,7 @@ class TestSDDBase(SavepointCase): "code": "AJ-PURC", "type": "purchase", "company_id": cls.company_B.id, - "payment_debit_account_id": cls.account_expense_company_B.id, - "payment_credit_account_id": cls.account_expense_company_B.id, + "default_account_id": cls.account_expense_company_B.id, } ) cls.journal_sale_company_B = cls.env["account.journal"].create( @@ -204,8 +215,7 @@ class TestSDDBase(SavepointCase): "code": "AJ-SALE", "type": "sale", "company_id": cls.company_B.id, - "payment_debit_account_id": cls.account_income_company_B.id, - "payment_credit_account_id": cls.account_income_company_B.id, + "default_account_id": cls.account_income_company_B.id, } ) cls.journal_general_company_B = cls.env["account.journal"].create( diff --git a/requirements.txt b/requirements.txt index a3b88976e..7640975a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ # generated from manifests external_dependencies lxml +python-stdnum unidecode