Skip to content
Extraits de code Groupes Projets
Valider 7cf12e5a rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[add] IBAN validation on SDD

parent 548aae3c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models, api from odoo import fields, models, api
from odoo.exceptions import ValidationError
class AccountPaymentOrder(models.Model): class AccountPaymentOrder(models.Model):
...@@ -76,3 +77,29 @@ class AccountPaymentOrder(models.Model): ...@@ -76,3 +77,29 @@ class AccountPaymentOrder(models.Model):
'search_view_id': [search_id, 'search'], 'search_view_id': [search_id, 'search'],
'domain': [['payment_order_id', '=', self.id]], 'domain': [['payment_order_id', '=', self.id]],
} }
# ------------------------------------------------------
# Common function
# ------------------------------------------------------
@api.multi
def check_sepa_order(self):
for order in self:
if not order.sepa:
msg = "Les comptes bancaires des coopératives suivantes ne sont pas corrects : \n"
payment_line_ids = order.payment_line_ids.mapped('partner_bank_id')
account_ids = payment_line_ids.filtered(lambda a: a.acc_type != 'iban')
for acc in account_ids:
msg += ' - ' + acc.partner_id.name + " - " + acc.acc_number + "\n"
msg += "\nVeuillez corriger ces comptes bancaires pour pouvoir valider l'ordre de prélèvement."
raise ValidationError(msg)
else:
return True
# ------------------------------------------------------
# Override Parent
# ------------------------------------------------------
@api.multi
def open2generated(self):
self.check_sepa_order()
return super(AccountPaymentOrder, self).open2generated()
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter