mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Merge pull request #256 from Antiun/imp-sepa_per_payment_mode
[8.0][IMP][account_banking_*] Define SEPA identifiers per payment mode
This commit is contained in:
@@ -39,7 +39,7 @@ Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* no known issues
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
@@ -62,6 +62,7 @@ Contributors
|
||||
* Raphaël Valyi
|
||||
* Sandy Carter
|
||||
* Stefan Rijnhart (Therp)
|
||||
* Antonio Espinosa <antonioea@antiun.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2015 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Account Banking PAIN Base Module',
|
||||
'summary': 'Base module for PAIN file generation',
|
||||
'version': '8.0.0.3.0',
|
||||
'version': '8.0.0.4.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': "Akretion, "
|
||||
"Noviat, "
|
||||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
|
||||
"Antiun Ingeniería S.L., "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/OCA/bank-payment',
|
||||
'contributors': ['Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>'],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2015 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, api, _
|
||||
@@ -234,12 +235,13 @@ class BankingExportPain(models.AbstractModel):
|
||||
initiating_party_1_8 = etree.SubElement(parent_node, 'InitgPty')
|
||||
initiating_party_name = etree.SubElement(initiating_party_1_8, 'Nm')
|
||||
initiating_party_name.text = my_company_name
|
||||
initiating_party_identifier =\
|
||||
self.payment_order_ids[0].company_id.\
|
||||
initiating_party_identifier
|
||||
initiating_party_issuer =\
|
||||
self.payment_order_ids[0].company_id.\
|
||||
initiating_party_issuer
|
||||
payment = self.payment_order_ids[0]
|
||||
initiating_party_identifier = (
|
||||
payment.mode.initiating_party_identifier or
|
||||
payment.company_id.initiating_party_identifier)
|
||||
initiating_party_issuer = (
|
||||
payment.mode.initiating_party_issuer or
|
||||
payment.company_id.initiating_party_issuer)
|
||||
if initiating_party_identifier and initiating_party_issuer:
|
||||
iniparty_id = etree.SubElement(initiating_party_1_8, 'Id')
|
||||
iniparty_org_id = etree.SubElement(iniparty_id, 'OrgId')
|
||||
@@ -254,7 +256,7 @@ class BankingExportPain(models.AbstractModel):
|
||||
_("Missing 'Initiating Party Issuer' and/or "
|
||||
"'Initiating Party Identifier' for the company '%s'. "
|
||||
"Both fields must have a value.")
|
||||
% self.payment_order_ids[0].company_id.name)
|
||||
% payment.company_id.name)
|
||||
return True
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2015 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, fields
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class PaymentMode(models.Model):
|
||||
@@ -14,3 +15,35 @@ class PaymentMode(models.Model):
|
||||
help="If active, Odoo will convert each accented caracter to "
|
||||
"the corresponding unaccented caracter, so that only ASCII "
|
||||
"caracters are used in the generated PAIN file.")
|
||||
initiating_party_issuer = fields.Char(
|
||||
string='Initiating Party Issuer', size=35,
|
||||
help="This will be used as the 'Initiating Party Issuer' in the "
|
||||
"PAIN files generated by Odoo. If not defined, Initiating Party "
|
||||
"Issuer from company will be used.\n"
|
||||
"Common format (13): \n"
|
||||
"- Country code (2, optional)\n"
|
||||
"- Company idenfier (N, VAT)\n"
|
||||
"- Service suffix (N, issued by bank)")
|
||||
initiating_party_identifier = fields.Char(
|
||||
string='Initiating Party Identifier', size=35,
|
||||
help="This will be used as the 'Initiating Party Identifier' in "
|
||||
"the PAIN files generated by Odoo. If not defined, Initiating Party "
|
||||
"Identifier from company will be used.\n"
|
||||
"Common format (13): \n"
|
||||
"- Country code (2, optional)\n"
|
||||
"- Company idenfier (N, VAT)\n"
|
||||
"- Service suffix (N, issued by bank)")
|
||||
sepa_type = fields.Char(compute="_compute_sepa_type")
|
||||
|
||||
def _sepa_type_get(self):
|
||||
"""Defined to be inherited by child addons, for instance:
|
||||
- account_banking_sepa_credit_transfer
|
||||
- account_banking_sepa_direct_debit
|
||||
"""
|
||||
return False
|
||||
|
||||
@api.multi
|
||||
@api.depends('type')
|
||||
def _compute_sepa_type(self):
|
||||
for mode in self:
|
||||
mode.sepa_type = mode._sepa_type_get()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<!--
|
||||
Copyright (C) 2013 Akretion (http://www.akretion.com)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
© 2015 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
<openerp>
|
||||
@@ -15,6 +16,16 @@
|
||||
<field name="type" position="after">
|
||||
<field name="convert_to_ascii"/>
|
||||
</field>
|
||||
<xpath expr="//form/group" position="after">
|
||||
<group name="sepa_identifiers" string="SEPA identifiers"
|
||||
attrs="{'invisible': [('sepa_type', '=', False)]}">
|
||||
<field name="sepa_type" invisible="1"/>
|
||||
<group>
|
||||
<field name="initiating_party_identifier" />
|
||||
<field name="initiating_party_issuer"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License: AGPL-3
|
||||
|
||||
|
||||
Account Banking SEPA Credit Transfer
|
||||
====================================
|
||||
|
||||
@@ -47,7 +47,7 @@ Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* No known issues
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
@@ -62,15 +62,16 @@ Credits
|
||||
Contributors
|
||||
------------
|
||||
|
||||
Alexis de Lattre
|
||||
Pedro M. Baeza
|
||||
Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
Stefan Rijnhart
|
||||
Julien Laloux
|
||||
Alexandre Fayolle
|
||||
Raphaël Valyi
|
||||
Erwin van der Ploeg
|
||||
Sandy Carter
|
||||
* Alexis de Lattre
|
||||
* Pedro M. Baeza
|
||||
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
* Stefan Rijnhart
|
||||
* Julien Laloux
|
||||
* Alexandre Fayolle
|
||||
* Raphaël Valyi
|
||||
* Erwin van der Ploeg
|
||||
* Sandy Carter
|
||||
* Antonio Espinosa <antonioea@antiun.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2010-2013 Akretion (www.akretion.com)
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2010-2015 Akretion (www.akretion.com)
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Account Banking SEPA Credit Transfer',
|
||||
'summary': 'Create SEPA XML files for Credit Transfers',
|
||||
'version': '8.0.0.4.0',
|
||||
'version': '8.0.0.5.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': "Akretion, "
|
||||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
|
||||
"Antiun Ingeniería S.L., "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/OCA/bank-payment',
|
||||
'category': 'Banking addons',
|
||||
|
||||
3
account_banking_sepa_credit_transfer/models/__init__.py
Normal file
3
account_banking_sepa_credit_transfer/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import payment_mode
|
||||
16
account_banking_sepa_credit_transfer/models/payment_mode.py
Normal file
16
account_banking_sepa_credit_transfer/models/payment_mode.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models
|
||||
|
||||
|
||||
class PaymentMode(models.Model):
|
||||
_inherit = 'payment.mode'
|
||||
|
||||
def _sepa_type_get(self):
|
||||
res = super(PaymentMode, self)._sepa_type_get()
|
||||
if not res:
|
||||
if self.type.code and self.type.code.startswith('pain.001'):
|
||||
res = 'sepa_credit_transfer'
|
||||
return res
|
||||
@@ -49,7 +49,7 @@ Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* No known issues
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
@@ -64,13 +64,13 @@ Credits
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Firsname Lastname <email.address@acsone.eu>
|
||||
* Alexis de Lattre
|
||||
* Pedro M. Baeza
|
||||
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
* Alexandre Fayolle
|
||||
* Raphaël Valyi
|
||||
* Sandy Carter
|
||||
* Antonio Espinosa <antonioea@antiun.com>
|
||||
|
||||
|
||||
Maintainer
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2015 Akretion (www.akretion.com)
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Account Banking SEPA Direct Debit',
|
||||
'summary': 'Create SEPA files for Direct Debit',
|
||||
'version': '8.0.0.3.0',
|
||||
'version': '8.0.0.4.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': "Akretion, "
|
||||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
|
||||
"Antiun Ingeniería S.L., "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/OCA/bank-payment',
|
||||
'category': 'Banking addons',
|
||||
@@ -21,6 +23,7 @@
|
||||
'data': [
|
||||
'views/account_banking_mandate_view.xml',
|
||||
'views/res_company_view.xml',
|
||||
'views/payment_mode_view.xml',
|
||||
'wizard/export_sdd_view.xml',
|
||||
'data/mandate_expire_cron.xml',
|
||||
'data/payment_type_sdd.xml',
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
from . import res_company
|
||||
from . import account_banking_mandate
|
||||
from . import bank_payment_line
|
||||
from . import payment_mode
|
||||
|
||||
39
account_banking_sepa_direct_debit/models/common.py
Normal file
39
account_banking_sepa_direct_debit/models/common.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013 Akretion (www.akretion.com)
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_sepa_creditor_identifier_valid(sepa_creditor_identifier):
|
||||
"""Check if SEPA Creditor Identifier is valid
|
||||
@param sepa_creditor_identifier: SEPA Creditor Identifier as str
|
||||
or unicode
|
||||
@return: True if valid, False otherwise
|
||||
"""
|
||||
if not isinstance(sepa_creditor_identifier, (str, unicode)):
|
||||
return False
|
||||
try:
|
||||
sci = str(sepa_creditor_identifier).lower()
|
||||
except:
|
||||
logger.warning(
|
||||
"SEPA Creditor ID should contain only ASCII caracters.")
|
||||
return False
|
||||
if len(sci) < 9:
|
||||
return False
|
||||
before_replacement = sci[7:] + sci[0:2] + '00'
|
||||
logger.debug(
|
||||
"SEPA ID check before_replacement = %s" % before_replacement)
|
||||
after_replacement = ''
|
||||
for char in before_replacement:
|
||||
if char.isalpha():
|
||||
after_replacement += str(ord(char) - 87)
|
||||
else:
|
||||
after_replacement += char
|
||||
logger.debug(
|
||||
"SEPA ID check after_replacement = %s" % after_replacement)
|
||||
return int(sci[2:4]) == (98 - (int(after_replacement) % 97))
|
||||
42
account_banking_sepa_direct_debit/models/payment_mode.py
Normal file
42
account_banking_sepa_direct_debit/models/payment_mode.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, fields, api, exceptions, _
|
||||
from .common import is_sepa_creditor_identifier_valid
|
||||
|
||||
|
||||
class PaymentMode(models.Model):
|
||||
_inherit = 'payment.mode'
|
||||
|
||||
sepa_creditor_identifier = fields.Char(
|
||||
string='SEPA Creditor Identifier', size=35,
|
||||
help="Enter the Creditor Identifier that has been attributed to your "
|
||||
"company to make SEPA Direct Debits. If not defined, "
|
||||
"SEPA Creditor Identifier from company will be used.\n"
|
||||
"This identifier is composed of :\n"
|
||||
"- your country ISO code (2 letters)\n"
|
||||
"- a 2-digits checkum\n"
|
||||
"- a 3-letters business code\n"
|
||||
"- a country-specific identifier")
|
||||
original_creditor_identifier = fields.Char(
|
||||
string='Original Creditor Identifier', size=70,
|
||||
help="If not defined, Original Creditor Identifier from company "
|
||||
"will be used.")
|
||||
|
||||
def _sepa_type_get(self):
|
||||
res = super(PaymentMode, self)._sepa_type_get()
|
||||
if not res:
|
||||
if self.type.code and self.type.code.startswith('pain.008'):
|
||||
res = 'sepa_direct_debit'
|
||||
return res
|
||||
|
||||
@api.one
|
||||
@api.constrains('sepa_creditor_identifier')
|
||||
def _check_sepa_creditor_identifier(self):
|
||||
if self.sepa_creditor_identifier:
|
||||
if not is_sepa_creditor_identifier_valid(
|
||||
self.sepa_creditor_identifier):
|
||||
raise exceptions.Warning(
|
||||
_('Error'),
|
||||
_("Invalid SEPA Creditor Identifier."))
|
||||
@@ -1,12 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013 Akretion (www.akretion.com)
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, fields, api, exceptions, _
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
from .common import is_sepa_creditor_identifier_valid
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
@@ -22,41 +21,11 @@ class ResCompany(models.Model):
|
||||
original_creditor_identifier = fields.Char(
|
||||
string='Original Creditor Identifier', size=70)
|
||||
|
||||
def is_sepa_creditor_identifier_valid(
|
||||
self, sepa_creditor_identifier):
|
||||
"""Check if SEPA Creditor Identifier is valid
|
||||
@param sepa_creditor_identifier: SEPA Creditor Identifier as str
|
||||
or unicode
|
||||
@return: True if valid, False otherwise
|
||||
"""
|
||||
if not isinstance(sepa_creditor_identifier, (str, unicode)):
|
||||
return False
|
||||
try:
|
||||
sci = str(sepa_creditor_identifier).lower()
|
||||
except:
|
||||
logger.warning(
|
||||
"SEPA Creditor ID should contain only ASCII caracters.")
|
||||
return False
|
||||
if len(sci) < 9:
|
||||
return False
|
||||
before_replacement = sci[7:] + sci[0:2] + '00'
|
||||
logger.debug(
|
||||
"SEPA ID check before_replacement = %s" % before_replacement)
|
||||
after_replacement = ''
|
||||
for char in before_replacement:
|
||||
if char.isalpha():
|
||||
after_replacement += str(ord(char) - 87)
|
||||
else:
|
||||
after_replacement += char
|
||||
logger.debug(
|
||||
"SEPA ID check after_replacement = %s" % after_replacement)
|
||||
return int(sci[2:4]) == (98 - (int(after_replacement) % 97))
|
||||
|
||||
@api.one
|
||||
@api.constrains('sepa_creditor_identifier')
|
||||
def _check_sepa_creditor_identifier(self):
|
||||
if self.sepa_creditor_identifier:
|
||||
if not self.is_sepa_creditor_identifier_valid(
|
||||
if not is_sepa_creditor_identifier_valid(
|
||||
self.sepa_creditor_identifier):
|
||||
raise exceptions.Warning(
|
||||
_('Error'),
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_payment_mode_form_inherit" model="ir.ui.view">
|
||||
<field name="name">Add SEPA identifiers</field>
|
||||
<field name="model">payment.mode</field>
|
||||
<field name="inherit_id" ref="account_banking_pain_base.view_payment_mode_form_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="sepa_identifiers" position="inside">
|
||||
<group>
|
||||
<field name="sepa_creditor_identifier"
|
||||
attrs="{'invisible': [('sepa_type', '!=', 'sepa_direct_debit')]}"/>
|
||||
<field name="original_creditor_identifier"
|
||||
attrs="{'invisible': [('sepa_type', '!=', 'sepa_direct_debit')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -224,6 +224,8 @@ class BankingExportSddWizard(models.TransientModel):
|
||||
payment_info_2_0, 'CdtrSchmeId')
|
||||
self.generate_creditor_scheme_identification(
|
||||
creditor_scheme_identification_2_27,
|
||||
'self.payment_order_ids[0].mode.'
|
||||
'sepa_creditor_identifier or'
|
||||
'self.payment_order_ids[0].company_id.'
|
||||
'sepa_creditor_identifier',
|
||||
'SEPA Creditor Identifier', {'self': self}, 'SEPA', gen_args)
|
||||
@@ -325,6 +327,8 @@ class BankingExportSddWizard(models.TransientModel):
|
||||
amendment_info_details_2_51, 'OrgnlCdtrSchmeId')
|
||||
self.generate_creditor_scheme_identification(
|
||||
ori_creditor_scheme_id_2_53,
|
||||
'self.payment_order_ids[0].mode.'
|
||||
'original_creditor_identifier or'
|
||||
'self.payment_order_ids[0].company_id.'
|
||||
'original_creditor_identifier',
|
||||
'Original Creditor Identifier',
|
||||
|
||||
Reference in New Issue
Block a user