[ADD] Added a module to easily enter RIBs (standard French bank details slips).
bzr revid: ls@numerigraphe.fr-20090617072715-hdkf86qq0nskc5q7
This commit is contained in:
parent
071306ec7d
commit
3d98f01646
|
@ -0,0 +1,26 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import base_rib
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
'name': 'RIB',
|
||||
'version': '0.1',
|
||||
'category': 'Generic Modules/Base',
|
||||
'description': """
|
||||
This module install the base for RIB bank accounts (French standard for bank accounts).
|
||||
To make it easier to enter RIB data, it will also allow to search for banks by code.
|
||||
|
||||
""",
|
||||
"author" : "Numérigraphe SARL",
|
||||
'depends': ['base', 'account'],
|
||||
'init_xml': ['base_rib_data.xml', ],
|
||||
'update_xml': ['base_rib_view.xml', ],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,112 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import string
|
||||
import unicodedata
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
|
||||
# Add fields and behavior for French RIB
|
||||
class res_partner_bank(osv.osv):
|
||||
_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 or 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)
|
||||
# Note: maketrans and translate work best with latin1 - that should not be a problem for RIB data
|
||||
rib = rib.lower().encode('latin-1').translate(string.maketrans(u'abcdefghijklmnopqrstuvwxyz', u'12345678912345678923456789'))
|
||||
|
||||
# compute the key
|
||||
key = 97 - (100 * int(rib)) % 97
|
||||
|
||||
if int(bank_acc.key) != key:
|
||||
return False
|
||||
return True
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
#overwrite the search method in order to search not only on bank type == basic account number but also on type == rib
|
||||
res = super(res_partner_bank, self).search(cr, uid, args, offset, limit, order, context=context, count=count)
|
||||
if filter(lambda x:x[0] == 'acc_number' , args):
|
||||
#get the value of the search
|
||||
rib_value = filter(lambda x:x[0] == 'acc_number' , args)[0][2]
|
||||
#get the other arguments of the search
|
||||
args1 = filter(lambda x:x[0] != 'acc_number' , args)
|
||||
#add the new criterion
|
||||
args1 += [('rib', 'ilike', rib_value)]
|
||||
#append the results to the older search
|
||||
res += super(res_partner_bank, self).search(cr, uid, args1, offset, limit,
|
||||
order, context=context, count=count)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'office': fields.char('Office Code', size=5, readonly=True, help="Office Code"),
|
||||
'key': fields.char('Key', size=2, readonly=True, help="The key is a number allowing to check the correctness of the other codes."),
|
||||
}
|
||||
|
||||
_constraints = [(_check_key, "The RIB key does not correspond to the other codes.", ["key"])]
|
||||
|
||||
res_partner_bank()
|
||||
|
||||
# overload the name_search method on banks to make it easier to enter RIB data
|
||||
class res_bank(osv.osv):
|
||||
_inherit = 'res.bank'
|
||||
|
||||
# allow a search by code
|
||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||
if not args:
|
||||
args = []
|
||||
if context is None:
|
||||
context = {}
|
||||
ids = []
|
||||
if name:
|
||||
ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context)
|
||||
if not ids:
|
||||
ids = self.search(cr, user, [('code', operator, name)] + args, limit=limit, context=context)
|
||||
return self.name_get(cr, user, ids, context)
|
||||
|
||||
# show the code before the name
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
result = []
|
||||
for bank in self.browse(cr, uid, ids, context):
|
||||
result.append((bank.id, (bank.code and (bank.code + ' - ') or '') + bank.name))
|
||||
return result
|
||||
|
||||
res_bank()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--
|
||||
Default bank account description
|
||||
-->
|
||||
<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_field" model="res.partner.bank.type.field">
|
||||
<field name="name">bank</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>
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- add the fields for French RIB to the partner form (subform)-->
|
||||
<record id="view_partner_rib0_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.form.rib0.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="bank" position="replace"/>
|
||||
</field>
|
||||
</record>
|
||||
<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" />
|
||||
<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>
|
||||
<!--
|
||||
<record id="view_partner_bank_rib1_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.form.rib1.inherit</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
<field name="inherit_id" ref="base.view_partner_bank_form" />
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="acc_number" position="before">
|
||||
<newline />
|
||||
<field name="rib_bank" />
|
||||
<field name="rib_office" />
|
||||
<newline />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_partner_bank_rib2_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.form.rib2.inherit</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
<field name="inherit_id" ref="base.view_partner_bank_form" />
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="acc_number" position="after">
|
||||
<field name="rib_key" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_partner_bank_rib1_tree" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.tree.rib1.inherit</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
<field name="inherit_id" ref="base.view_partner_bank_tree" />
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="acc_number" position="before">
|
||||
<field name="rib_bank" />
|
||||
<field name="rib_office" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_partner_bank_rib2_tree" model="ir.ui.view">
|
||||
<field name="name">res.partner.bank.tree.rib2.inherit</field>
|
||||
<field name="model">res.partner.bank</field>
|
||||
<field name="inherit_id" ref="base.view_partner_bank_tree" />
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="acc_number" position="after">
|
||||
<field name="rib_key" />
|
||||
</field>
|
||||
</field>
|
||||
</record> -->
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,81 @@
|
|||
# Translation of OpenERP Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * base_rib
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: OpenERP Server 5.0.1\n"
|
||||
"Report-Msgid-Bugs-To: support@openerp.com\n"
|
||||
"POT-Creation-Date: 2009-06-16 14:15:16+0000\n"
|
||||
"PO-Revision-Date: 2009-06-16 14:15:16+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: base_rib
|
||||
#: model:res.partner.bank.type.field,name:base_rib.rib_key_field
|
||||
msgid "key"
|
||||
msgstr "key"
|
||||
|
||||
#. module: base_rib
|
||||
#: constraint:ir.ui.view:0
|
||||
msgid "Invalid XML for View Architecture!"
|
||||
msgstr "XML non valide pour l'architecture de la vue"
|
||||
|
||||
#. module: base_rib
|
||||
#: model:ir.module.module,description:base_rib.module_meta_information
|
||||
msgid "\n"
|
||||
"This module install 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.\n"
|
||||
"\n"
|
||||
" "
|
||||
msgstr "\n"
|
||||
"Ce module configure la base pour la saisie des RIB (Relevés d'Identité Bancaires) standards français. \n"
|
||||
"Pour faciliter la saisie des RIB, il permet également une recherche des banques par code.\n"
|
||||
"\n"
|
||||
" "
|
||||
|
||||
#. module: base_rib
|
||||
#: model:res.partner.bank.type.field,name:base_rib.rib_office_field
|
||||
msgid "office"
|
||||
msgstr "Agence"
|
||||
|
||||
#. module: base_rib
|
||||
#: field:res.partner.bank,office:0
|
||||
#: help:res.partner.bank,office:0
|
||||
msgid "Office Code"
|
||||
msgstr "Code agence"
|
||||
|
||||
#. module: base_rib
|
||||
#: model:res.partner.bank.type,name:base_rib.bank_rib
|
||||
msgid "RIB Bank Details"
|
||||
msgstr "Relevé d'identité bancaire (RIB)"
|
||||
|
||||
#. module: base_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: base_rib
|
||||
#: field:res.partner.bank,key:0
|
||||
msgid "Key"
|
||||
msgstr "Clé"
|
||||
|
||||
#. module: base_rib
|
||||
#: model:ir.module.module,shortdesc:base_rib.module_meta_information
|
||||
msgid "RIB"
|
||||
msgstr "RIB"
|
||||
|
||||
#. module: base_rib
|
||||
#: model:res.partner.bank.type.field,name:base_rib.rib_bank_field
|
||||
msgid "bank"
|
||||
msgstr "bank"
|
||||
|
||||
#. module: base_rib
|
||||
#: model:res.partner.bank.type.field,name:base_rib.bank_acc_number_field
|
||||
msgid "acc_number"
|
||||
msgstr "acc_number"
|
||||
|
Loading…
Reference in New Issue