[MERGE] l10n_fr_rib module added, courtesy of Numerigraphe

bzr revid: odo@openerp.com-20111201135527-1eyicb565vmn21r0
This commit is contained in:
Olivier Dony
2011-12-01 14:55:27 +01:00
7 changed files with 506 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import bank
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+48
View File
@@ -0,0 +1,48 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'French RIB Bank Details',
'version': '1.0',
'category': 'Hidden',
'description': '''
This module lets users enter the banking details of Partners in the RIB format (French standard for bank accounts details).
RIB Bank Accounts can be entered in the "Accounting" tab of the Partner form by specifying the account type "RIB". The four standard RIB fields will then become mandatory:
- Bank Code
- Office Code
- Account number
- RIB key
As a safety measure, OpenERP will check the RIB key whenever a RIB is saved, and will refuse to record the data if the key is incorrect. Please bear in mind that this can only happen when the user presses the "save" button, for example on the Partner Form.
Since each bank account may relate to a Bank, users may enter the RIB Bank Code in the Bank form - it will the pre-fill the Bank Code on the RIB when they select the Bank.
To make this easier, this module will also let users find Banks using their RIB code.
The module base_iban can be a useful addition to this module, because French banks are now progressively adopting the international IBAN format instead of the RIB format.
The RIB and IBAN codes for a single account can be entered by recording two Bank Accounts in OpenERP: the first with the type "RIB", the second with the type "IBAN".
''',
'author' : u'Numérigraphe SARL',
'depends': ['base', 'account'],
'init_xml': ['bank_data.xml', ],
'update_xml': ['bank_view.xml', ],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+117
View File
@@ -0,0 +1,117 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import netsvc
from osv import fields, osv
from tools.translate import _
class res_partner_bank(osv.osv):
"""Add fields and behavior for French RIB"""
_inherit = "res.partner.bank"
def _check_key(self, cr, uid, ids):
"""Check the RIB key"""
for bank_acc in self.browse(cr, uid, ids):
# Ignore the accounts of type other than rib
if bank_acc.state !='rib':
continue
# Fail if the needed values are empty of too short
if (not bank_acc.bank_code
or len(bank_acc.bank_code) != 5
or not bank_acc.office or len(bank_acc.office) != 5
or not bank_acc.acc_number or len(bank_acc.acc_number) != 11
or not bank_acc.key or len(bank_acc.key) != 2):
return False
# Get the rib data (without the key)
rib = "%s%s%s" % (bank_acc.bank_code, bank_acc.office,
bank_acc.acc_number)
# Translate letters into numbers according to a specific table
# (notice how s -> 2)
table = dict((ord(a), b) for a, b in zip(
u'abcdefghijklmnopqrstuvwxyz', u'12345678912345678923456789'))
rib = rib.lower().translate(table)
# compute the key
key = 97 - (100 * int(rib)) % 97
if int(bank_acc.key) != key:
return False
return True
def onchange_bank_id(self, cr, uid, ids, bank_id, context=None):
"""Change the bank code"""
result = super(res_partner_bank, self).onchange_bank_id(cr, uid, ids, bank_id,
context=context)
if bank_id:
bank = self.pool.get('res.bank').browse(cr, uid, bank_id,
context=context)
result['bank_code'] = bank.rib_code
return {'value': result}
_columns = {
'bank_code': fields.char('Bank Code', size=64, readonly=True,),
'office': fields.char('Office Code', size=5, readonly=True,),
'key': fields.char('Key', size=2, readonly=True,
help="The key is a number allowing to check the "
"correctness of the other codes."),
}
def _construct_constraint_msg(self, cr, uid, ids, context=None):
"""Quote the data in the warning message"""
# Only process the first id
if type(ids) not in (int, long):
id = ids[0]
rib = self.browse(cr, uid, id, context=context)
if rib:
return (_("\nThe RIB key %s does not correspond to the other "
"codes: %s %s %s.") %
(rib.key,
rib.bank_code,
rib.office,
rib.acc_number) )
_constraints = [(_check_key,
_construct_constraint_msg,
["key"])]
res_partner_bank()
class res_bank(osv.osv):
"""Add the bank code to make it easier to enter RIB data"""
_inherit = 'res.bank'
def name_search(self, cr, user, name, args=None, operator='ilike',
context=None, limit=80):
"""Search by bank code in addition to the standard search"""
# Get the standard results
results = super(res_bank, self).name_search(cr, user,
name, args=args ,operator=operator, context=context, limit=limit)
# Get additional results using the RIB code
ids = self.search(cr, user, [('rib_code', operator, name)],
limit=limit, context=context)
# Merge the results
results = list(set(results + self.name_get(cr, user, ids, context)))
return results
_columns = {
'rib_code': fields.char('RIB Bank Code', size=64),
}
res_bank()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+44
View File
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
RIB bank details
-->
<record id="bank_rib" model="res.partner.bank.type">
<field name="name">RIB Bank Details</field>
<field name="code">rib</field>
</record>
<record id="rib_bank_code_field" model="res.partner.bank.type.field">
<field name="name">bank_code</field>
<field name="bank_type_id" ref="bank_rib"/>
<field eval="True" name="required"/>
<field eval="False" name="readonly"/>
</record>
<record id="rib_office_field" model="res.partner.bank.type.field">
<field name="name">office</field>
<field name="bank_type_id" ref="bank_rib"/>
<field eval="True" name="required"/>
<field eval="False" name="readonly"/>
</record>
<record id="bank_acc_number_field" model="res.partner.bank.type.field">
<field name="name">acc_number</field>
<field name="bank_type_id" ref="bank_rib"/>
<field eval="True" name="required"/>
<field eval="False" name="readonly"/>
<field name="size">11</field>
</record>
<record id="rib_key_field" model="res.partner.bank.type.field">
<field name="name">key</field>
<field name="bank_type_id" ref="bank_rib"/>
<field eval="True" name="required"/>
<field eval="False" name="readonly"/>
</record>
<record id="rib_bic_field" model="res.partner.bank.type.field">
<field name="name">bank_bic</field>
<field name="bank_type_id" ref="bank_rib"/>
<field name="required" eval="0"/>
</record>
</data>
</openerp>
+44
View File
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- add the fields for French RIB to the partner form (subform)-->
<record id="view_partner_rib1_form" model="ir.ui.view">
<field name="name">res.partner.form.rib1.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<field name="acc_number" position="before">
<newline />
<field name="bank_code" />
<field name="office" />
<newline />
</field>
</field>
</record>
<record id="view_partner_rib2_form" model="ir.ui.view">
<field name="name">res.partner.form.rib2.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<field name="acc_number" position="after">
<field name="key" />
</field>
</field>
</record>
<!-- add the bank code-->
<record id="view_res_bank_form" model="ir.ui.view">
<field name="name">res.bank.form.rib.inherit</field>
<field name="model">res.bank</field>
<field name="inherit_id" ref="base.view_res_bank_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<field name="bic" position="before">
<field name="rib_code" />
</field>
</field>
</record>
</data>
</openerp>
+116
View File
@@ -0,0 +1,116 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_fr_rib
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1beta\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-11-21 12:37+0000\n"
"PO-Revision-Date: 2011-11-21 12:37+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: l10n_fr_rib
#: constraint:res.partner.bank:0
msgid "\n"
"Please define BIC/Swift code on bank for bank type IBAN Account to make valid payments"
msgstr "\n"
"Please define BIC/Swift code on bank for bank type IBAN Account to make valid payments"
#. module: l10n_fr_rib
#: model:ir.model,name:l10n_fr_rib.model_res_partner_bank
msgid "Bank Accounts"
msgstr "Comptes bancaires"
#. module: l10n_fr_rib
#: field:res.partner.bank,bank_code:0
msgid "Bank Code"
msgstr "Code banque"
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_bic_field
msgid "bank_bic"
msgstr "bank_bic"
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_office_field
msgid "office"
msgstr "Agence"
#. module: l10n_fr_rib
#: field:res.bank,rib_code:0
msgid "RIB Bank Code"
msgstr "Code banque RIB"
#. module: l10n_fr_rib
#: model:ir.module.module,description:l10n_fr_rib.module_meta_information
msgid "\n"
"This module installs the base for RIB bank accounts (French standard for bank accounts). \n"
"To make it easier to enter RIB data, it will also allow to search for banks by code."
msgstr "\n"
"Ce module installe la base pour les comptes bancaires RIB (norme française pour les n° de compte). \n"
"Pour faciliter la saisie des RIBs, il permet aussi de chercher les banques par code."
#. module: l10n_fr_rib
#: field:res.partner.bank,office:0
msgid "Office Code"
msgstr "Code agence"
#. module: l10n_fr_rib
#: model:res.partner.bank.type,name:l10n_fr_rib.bank_rib
msgid "RIB Bank Details"
msgstr "Relevé d'identité bancaire (RIB)"
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_bank_code_field
msgid "bank_code"
msgstr "bank_code"
#. module: l10n_fr_rib
#: code:addons/l10n_fr_rib/bank.py:109
#, python-format
msgid "\n"
"The RIB key %s does not correspond to the other codes: %s %s %s."
msgstr "\n"
"La clé RIB %s ne correspond pas aux autres codes : %s %s %s."
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_key_field
msgid "key"
msgstr "key"
#. module: l10n_fr_rib
#: model:ir.module.module,shortdesc:l10n_fr_rib.module_meta_information
msgid "French RIB Bank Details"
msgstr "Relevés d'identité bancaire français (RIB)"
#. module: l10n_fr_rib
#: help:res.partner.bank,key:0
msgid "The key is a number allowing to check the correctness of the other codes."
msgstr "La clé est un nombre permettant de vérifier que les autres codes sont corrects."
#. module: l10n_fr_rib
#: field:res.partner.bank,key:0
msgid "Key"
msgstr "Clé"
#. module: l10n_fr_rib
#: model:res.partner.bank.type,format_layout:l10n_fr_rib.bank_rib
msgid "%(bank_name)s: %(acc_number)s"
msgstr "%(bank_name)s: %(acc_number)s"
#. module: l10n_fr_rib
#: model:ir.model,name:l10n_fr_rib.model_res_bank
msgid "Bank"
msgstr "Banque"
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.bank_acc_number_field
msgid "acc_number"
msgstr "acc_number"
+112
View File
@@ -0,0 +1,112 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_fr_rib
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1beta\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-11-21 12:36+0000\n"
"PO-Revision-Date: 2011-11-21 12:36+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: l10n_fr_rib
#: constraint:res.partner.bank:0
msgid "\n"
"Please define BIC/Swift code on bank for bank type IBAN Account to make valid payments"
msgstr ""
#. module: l10n_fr_rib
#: model:ir.model,name:l10n_fr_rib.model_res_partner_bank
msgid "Bank Accounts"
msgstr ""
#. module: l10n_fr_rib
#: field:res.partner.bank,bank_code:0
msgid "Bank Code"
msgstr ""
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_bic_field
msgid "bank_bic"
msgstr ""
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_office_field
msgid "office"
msgstr ""
#. module: l10n_fr_rib
#: field:res.bank,rib_code:0
msgid "RIB Bank Code"
msgstr ""
#. module: l10n_fr_rib
#: model:ir.module.module,description:l10n_fr_rib.module_meta_information
msgid "\n"
"This module installs the base for RIB bank accounts (French standard for bank accounts). \n"
"To make it easier to enter RIB data, it will also allow to search for banks by code."
msgstr ""
#. module: l10n_fr_rib
#: field:res.partner.bank,office:0
msgid "Office Code"
msgstr ""
#. module: l10n_fr_rib
#: model:res.partner.bank.type,name:l10n_fr_rib.bank_rib
msgid "RIB Bank Details"
msgstr ""
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_bank_code_field
msgid "bank_code"
msgstr ""
#. module: l10n_fr_rib
#: code:addons/l10n_fr_rib/bank.py:109
#, python-format
msgid "\n"
"The RIB key %s does not correspond to the other codes: %s %s %s."
msgstr ""
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.rib_key_field
msgid "key"
msgstr ""
#. module: l10n_fr_rib
#: model:ir.module.module,shortdesc:l10n_fr_rib.module_meta_information
msgid "French RIB Bank Details"
msgstr ""
#. module: l10n_fr_rib
#: help:res.partner.bank,key:0
msgid "The key is a number allowing to check the correctness of the other codes."
msgstr ""
#. module: l10n_fr_rib
#: field:res.partner.bank,key:0
msgid "Key"
msgstr ""
#. module: l10n_fr_rib
#: model:res.partner.bank.type,format_layout:l10n_fr_rib.bank_rib
msgid "%(bank_name)s: %(acc_number)s"
msgstr ""
#. module: l10n_fr_rib
#: model:ir.model,name:l10n_fr_rib.model_res_bank
msgid "Bank"
msgstr ""
#. module: l10n_fr_rib
#: model:res.partner.bank.type.field,name:l10n_fr_rib.bank_acc_number_field
msgid "acc_number"
msgstr ""