diff --git a/addons/l10n_fr_rib/__init__.py b/addons/l10n_fr_rib/__init__.py new file mode 100644 index 00000000000..bdaab364c54 --- /dev/null +++ b/addons/l10n_fr_rib/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 OpenERP SA (). +# +# 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 . +# +############################################################################## + +import bank + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/l10n_fr_rib/__openerp__.py b/addons/l10n_fr_rib/__openerp__.py new file mode 100644 index 00000000000..16ae81fb431 --- /dev/null +++ b/addons/l10n_fr_rib/__openerp__.py @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 OpenERP SA (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'French RIB Bank Details', + 'version': '1.0', + 'category': 'Hidden', + 'description': ''' +This module installs 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' : 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: diff --git a/addons/l10n_fr_rib/bank.py b/addons/l10n_fr_rib/bank.py new file mode 100644 index 00000000000..cd8488f6dcd --- /dev/null +++ b/addons/l10n_fr_rib/bank.py @@ -0,0 +1,148 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 OpenERP SA (). +# +# 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 . +# +############################################################################## + +import string +import unicodedata + +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): + print """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) + print rib + # 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 + # XXX use dict((ord(a), b) for a, b in zip(intab, outtab)) + # and translate() + rib = rib.lower().encode('latin-1').translate( + string.maketrans(u'abcdefghijklmnopqrstuvwxyz', + u'12345678912345678923456789')) + print rib + # compute the key + key = 97 - (100 * int(rib)) % 97 + print int(bank_acc.key), key + 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): + """Search on type == rib""" + res = super(res_partner_bank, self).search(cr, uid, args, offset, + limit=limit, order=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 + + 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.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""" + if self._check_key(cr, uid, ids): + return + # 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""" + if args is None: + args = [] + 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) + + _columns = { + 'rib_code': fields.char('RIB Bank Code', size=64), + } +res_bank() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/l10n_fr_rib/bank_data.xml b/addons/l10n_fr_rib/bank_data.xml new file mode 100644 index 00000000000..1dc9f4c88fd --- /dev/null +++ b/addons/l10n_fr_rib/bank_data.xml @@ -0,0 +1,44 @@ + + + + + + + RIB Bank Details + rib + + + + bank_code + + + + + + office + + + + + + acc_number + + + + 11 + + + key + + + + + + bank_bic + + + + + diff --git a/addons/l10n_fr_rib/bank_view.xml b/addons/l10n_fr_rib/bank_view.xml new file mode 100644 index 00000000000..56eb8393aef --- /dev/null +++ b/addons/l10n_fr_rib/bank_view.xml @@ -0,0 +1,44 @@ + + + + + + res.partner.form.rib1.inherit + res.partner + + form + + + + + + + + + + + res.partner.form.rib2.inherit + res.partner + + form + + + + + + + + + + res.bank.form.rib.inherit + res.bank + + form + + + + + + + + diff --git a/addons/l10n_fr_rib/i18n/fr.po b/addons/l10n_fr_rib/i18n/fr.po new file mode 100644 index 00000000000..4057dafb803 --- /dev/null +++ b/addons/l10n_fr_rib/i18n/fr.po @@ -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" + diff --git a/addons/l10n_fr_rib/i18n/l10n_fr_rib.pot b/addons/l10n_fr_rib/i18n/l10n_fr_rib.pot new file mode 100644 index 00000000000..5db922fe20f --- /dev/null +++ b/addons/l10n_fr_rib/i18n/l10n_fr_rib.pot @@ -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 "" +