From 054109e9883c9219743e2cf5073328a284fe3c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 10 Dec 2014 16:51:48 +0100 Subject: [PATCH 1/3] [IMP] sepa credit tfr: get BIC from bank account if not available on bank Since the bank is optional on bank accounts and the BIC can be set on the bank account if there is no bank, we allow the system to get the BIC from the bank account in case it is not on the bank. We give priority to the BIC indicated on the bank, keeping the same behaviour with existing data where the bank BIC is available. --- account_banking_sepa_credit_transfer/wizard/export_sepa.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/account_banking_sepa_credit_transfer/wizard/export_sepa.py b/account_banking_sepa_credit_transfer/wizard/export_sepa.py index 94b2004a3..c9e941e54 100644 --- a/account_banking_sepa_credit_transfer/wizard/export_sepa.py +++ b/account_banking_sepa_credit_transfer/wizard/export_sepa.py @@ -195,7 +195,8 @@ class BankingExportSepaWizard(orm.TransientModel): 'sepa_export.payment_order_ids[0].mode.bank_id.partner_id.' 'name', 'sepa_export.payment_order_ids[0].mode.bank_id.acc_number', - 'sepa_export.payment_order_ids[0].mode.bank_id.bank.bic', + 'sepa_export.payment_order_ids[0].mode.bank_id.bank.bic or ' + 'sepa_export.payment_order_ids[0].mode.bank_id.bank_bic', {'sepa_export': sepa_export}, gen_args, context=context) charge_bearer_2_24 = etree.SubElement(payment_info_2_0, 'ChrgBr') @@ -236,7 +237,8 @@ class BankingExportSepaWizard(orm.TransientModel): self.generate_party_block( cr, uid, credit_transfer_transaction_info_2_27, 'Cdtr', 'C', 'line.partner_id.name', 'line.bank_id.acc_number', - 'line.bank_id.bank.bic', {'line': line}, gen_args, + 'line.bank_id.bank.bic or ' + 'line.bank_id.bank_bic', {'line': line}, gen_args, context=context) self.generate_remittance_info_block( cr, uid, credit_transfer_transaction_info_2_27, From 43cf7504899c1e52e063e9ac21647100a9f6e887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 22 Jan 2015 17:24:23 +0100 Subject: [PATCH 2/3] [IMP] sepa direct debit: get BIC from bank account if not available on bank --- .../wizard/export_sdd.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/account_banking_sepa_direct_debit/wizard/export_sdd.py b/account_banking_sepa_direct_debit/wizard/export_sdd.py index 2fffdda65..948fa68be 100644 --- a/account_banking_sepa_direct_debit/wizard/export_sdd.py +++ b/account_banking_sepa_direct_debit/wizard/export_sdd.py @@ -249,7 +249,8 @@ class BankingExportSddWizard(orm.TransientModel): 'sepa_export.payment_order_ids[0].mode.bank_id.partner_id.' 'name', 'sepa_export.payment_order_ids[0].mode.bank_id.acc_number', - 'sepa_export.payment_order_ids[0].mode.bank_id.bank.bic', + 'sepa_export.payment_order_ids[0].mode.bank_id.bank.bic or ' + 'sepa_export.payment_order_ids[0].mode.bank_id.bank_bic', {'sepa_export': sepa_export}, gen_args, context=context) charge_bearer_2_24 = etree.SubElement(payment_info_2_0, 'ChrgBr') @@ -316,7 +317,10 @@ class BankingExportSddWizard(orm.TransientModel): amendment_info_details_2_51 = etree.SubElement( mandate_related_info_2_47, 'AmdmntInfDtls') if previous_bank: - if previous_bank.bank.bic == line.bank_id.bank.bic: + if (previous_bank.bank.bic or + previous_bank.bank_bic) == \ + (line.bank_id.bank.bic or + line.bank_id.bank_bic): ori_debtor_account_2_57 = etree.SubElement( amendment_info_details_2_51, 'OrgnlDbtrAcct') ori_debtor_account_id = etree.SubElement( @@ -340,7 +344,8 @@ class BankingExportSddWizard(orm.TransientModel): ori_debtor_agent_institution, bic_xml_tag) ori_debtor_agent_bic.text = self._prepare_field( cr, uid, 'Original Debtor Agent', - 'previous_bank.bank.bic', + 'previous_bank.bank.bic or ' + 'previous_bank.bank_bic', {'previous_bank': previous_bank}, gen_args=gen_args, context=context) @@ -375,7 +380,8 @@ class BankingExportSddWizard(orm.TransientModel): cr, uid, dd_transaction_info_2_28, 'Dbtr', 'C', 'line.partner_id.name', 'line.bank_id.acc_number', - 'line.bank_id.bank.bic', + 'line.bank_id.bank.bic or ' + 'line.bank_id.bank_bic', {'line': line}, gen_args, context=context) self.generate_remittance_info_block( From f8b4ee8ebd681d55a9f60e44d797e759a85b554a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 22 Jan 2015 17:46:23 +0100 Subject: [PATCH 3/3] [IMP] help text for bank and BIC fields Courtesy Alexis de Lattre --- account_banking_pain_base/models/__init__.py | 1 + .../models/res_partner_bank.py | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 account_banking_pain_base/models/res_partner_bank.py diff --git a/account_banking_pain_base/models/__init__.py b/account_banking_pain_base/models/__init__.py index f1e6551bf..22b8d64ae 100644 --- a/account_banking_pain_base/models/__init__.py +++ b/account_banking_pain_base/models/__init__.py @@ -24,3 +24,4 @@ from . import payment_line from . import payment_mode from . import res_company from . import banking_export_pain +from . import res_partner_bank diff --git a/account_banking_pain_base/models/res_partner_bank.py b/account_banking_pain_base/models/res_partner_bank.py new file mode 100644 index 000000000..3c7a5ff0d --- /dev/null +++ b/account_banking_pain_base/models/res_partner_bank.py @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) ACSONE SA/NV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields + + +class ResPartnerBank(models.Model): + _inherit = 'res.partner.bank' + + bank = fields.Many2one(help="If this field is set and the related bank " + "has a 'Bank Identifier Code', then this BIC " + "will be used to generate the credit " + "transfers and direct debits files.") + bank_bic = fields.Char(help="In the generation of credit transfer and " + "direct debit files, this BIC will be used " + "only when the 'Bank' field is empty, or " + "has a value but the field 'Bank Identifier " + "Code' is not set on the related bank.")