From 7d64216916e15c2a275e1f1b5058f17e21f38912 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sun, 19 May 2019 16:39:33 +0200 Subject: [PATCH] [IMP] account_banking_sepa_direct_debit: Rise exception if the mandate type is not correct Closes #600 --- .../models/account_payment_order.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 298d922e1..4e0d5ec17 100644 --- a/account_banking_sepa_direct_debit/models/account_payment_order.py +++ b/account_banking_sepa_direct_debit/models/account_payment_order.py @@ -2,7 +2,7 @@ # Copyright 2018 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import _, api, exceptions, fields, models from odoo.exceptions import UserError from lxml import etree @@ -81,6 +81,11 @@ class AccountPaymentOrder(models.Model): seq_type_label = line.mandate_id.recurrent_sequence_type assert seq_type_label is not False seq_type = seq_type_map[seq_type_label] + else: + raise exceptions.UserError(_( + "Invalid mandate type in '%s'. Valid ones are 'Recurrent' " + "or 'One-Off'" + ) % line.mandate_id.unique_mandate_reference) # The field line.date is the requested payment date # taking into account the 'date_preferred' setting # cf account_banking_payment_export/models/account_payment.py