Lionel Sausin - Numérigraphe has proposed merging lp:~numerigraphe-team/account-financial-tools/7.0-l10n_fr_siret-view+company into lp:account-financial-tools.
Requested reviews: Account Core Editors (account-core-editors) For more details, see: https://code.launchpad.net/~numerigraphe-team/account-financial-tools/7.0-l10n_fr_siret-view+company/+merge/212920 This branch improves the module l10n_fr_siret : - the SIREN and BIC fields are only shown in edit mode - the SIRET field introduced by l10n_fr is replaced by a "related" field for consistency. -- https://code.launchpad.net/~numerigraphe-team/account-financial-tools/7.0-l10n_fr_siret-view+company/+merge/212920 Your team OpenERP Community Reviewer/Maintainer is subscribed to branch lp:account-financial-tools.
=== modified file 'l10n_fr_siret/__init__.py' --- l10n_fr_siret/__init__.py 2011-12-08 14:10:34 +0000 +++ l10n_fr_siret/__init__.py 2014-03-26 18:28:22 +0000 @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -20,6 +20,4 @@ ############################################################################## import partner - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +import company === modified file 'l10n_fr_siret/__openerp__.py' --- l10n_fr_siret/__openerp__.py 2013-02-26 16:15:55 +0000 +++ l10n_fr_siret/__openerp__.py 2014-03-26 18:28:22 +0000 @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -21,25 +21,32 @@ { 'name': 'French company identity numbers SIRET/SIREN/NIC', - 'version': '1.0', + 'version': '1.1', "category": 'Accounting', - 'description': """ -This module lets users keep track of the companies' unique -identification numbers from the official SIRENE registry in France: -SIRET, SIREN and NIC. These numbers identify each company and their -subsidiaries, and are often required for administrative tasks. - -At the top of the Partner form, users will be able to enter the SIREN + 'description': ''' +This module add the French company identity numbers. +==================================================== + +This can help any company doing business with French companies +by letting users track the partners' unique identification +numbers from the official SIRENE registry in France: SIRET, SIREN and NIC. +These numbers identify each company and their subsidiaries, and are +often required for administrative tasks. + +On the Partner form, users will be able to enter the SIREN and NIC numbers, and the SIRET number will be calculated automatically. The last digits of the SIREN and NIC are control keys: OpenERP will check their validity when partners are recorded. -""", - 'author' : u'Numérigraphe SARL', - 'depends': ['account'], - 'data': ['partner_view.xml', - ], + +ATTENTION! this module replaces the fields on the Company form with the new +ones on the Partner form, but it will NOT copy the corresponding data: you +will have to enter them again. +''', + 'author': u'Numérigraphe SARL', + 'depends': ['account', 'l10n_fr'], + 'data': [ + 'partner_view.xml', + ], 'installable': True, 'active': False, } - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added file 'l10n_fr_siret/company.py' --- l10n_fr_siret/company.py 1970-01-01 00:00:00 +0000 +++ l10n_fr_siret/company.py 2014-03-26 18:28:22 +0000 @@ -0,0 +1,41 @@ +# -*- coding: 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/>. +# +############################################################################## + +from openerp.osv import fields, orm + + +class res_company(orm.Model): + """Replace the company's fields for SIRET/RC with the ones on the partner""" + _inherit = 'res.company' + + def _get_partner_change(self, cr, uid, ids, context=None): + return self.pool.get('res.partner').search(cr, uid, [('partner_id', 'in', ids)], context=context) + + _columns = { + 'siret': fields.related( + 'partner_id', 'siret', type='char', store={ + 'product.product': (_get_partner_change, ['siren', 'nic'], 20), + 'res.company': (lambda self, cr, uid, ids, c={}: ids, ['partner_id'], 20), }), + 'company_registry': fields.related( + 'partner_id', 'company_registry', type='char', store={ + 'product.product': (_get_partner_change, ['company_registry'], 20), + 'res.company': (lambda self, cr, uid, ids, c={}: ids, ['partner_id'], 20), }) + } === modified file 'l10n_fr_siret/partner.py' --- l10n_fr_siret/partner.py 2013-02-05 16:03:32 +0000 +++ l10n_fr_siret/partner.py 2014-03-26 18:28:22 +0000 @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -27,10 +27,13 @@ def _check_luhn(string): """Luhn test to check control keys - Credits: http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Python + Credits: + http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Python """ r = [int(ch) for ch in string][::-1] - return (sum(r[0::2]) + sum(sum(divmod(d*2,10)) for d in r[1::2])) % 10 == 0 + return (sum(r[0::2]) + sum(sum(divmod(d * 2, 10)) + for d in r[1::2])) % 10 == 0 + class Partner(orm.Model): """Add the French official company identity numbers SIREN, NIC and SIRET""" @@ -51,16 +54,17 @@ for partner in self.browse(cr, uid, ids, context=None): if partner.nic: # Check the NIC type and length - if not partner.nic.isdecimal() or len(partner.nic)!=5: + if not partner.nic.isdecimal() or len(partner.nic) != 5: return False if partner.siren: # Check the SIREN type, length and key if (not partner.siren.isdecimal() - or len(partner.siren)!=9 - or not _check_luhn(partner.siren) ): + or len(partner.siren) != 9 + or not _check_luhn(partner.siren)): return False # Check the NIC key (you need both SIREN and NIC to check it) - if partner.nic and not _check_luhn(partner.siren + partner.nic): + if partner.nic and not _check_luhn(partner.siren + + partner.nic): return False return True @@ -74,26 +78,24 @@ "of this office in the company in France. It " "makes the last 5 digits of the SIRET " "number."), - 'siret': fields.function(_get_siret, type="char", string='SIRET', + 'siret': fields.function( + _get_siret, type="char", string='SIRET', method=True, size=14, - store = { + store={ 'res.partner': [lambda self, cr, uid, ids, context=None: ids, - ['siren', 'nic'], - 10]}, + ['siren', 'nic'], 10]}, help="The SIRET number is the official identity number of this " "company's office in France. It is composed of the 9 digits " "of the SIREN number and the 5 digits of the NIC number, ie. " "14 digits."), - 'company_registry': fields.char('Company Registry', size=64, - help="The name of official registry where this " - "company was declared."), + 'company_registry': fields.char( + 'Company Registry', size=64, + help="The name of official registry where this " + "company was declared."), } _constraints = [ - (_check_siret, - "The SIREN or NIC number is incorrect.", - ["siren", "nic"]), + (_check_siret, + "The SIREN or NIC number is incorrect.", + ["siren", "nic"]), ] - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === modified file 'l10n_fr_siret/partner_view.xml' --- l10n_fr_siret/partner_view.xml 2012-08-27 16:40:53 +0000 +++ l10n_fr_siret/partner_view.xml 2014-03-26 18:28:22 +0000 @@ -1,25 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> - <data> - <!-- Add the SIREN, NIC and SIRET numbers --> - <record model="ir.ui.view" id="view_partner_add"> - <field name="name">res.partner.form.siret</field> - <field name="model">res.partner</field> - <field name="inherit_id" ref="account.view_partner_property_form" /> - <field name="arch" type="xml"> - <page string="Accounting" position="inside"> - <group> - <group> - <field name="siren" /> - <field name="nic" /> - <field name="siret" /> - </group> - <group> - <field name="company_registry" /> - </group> - </group> - </page> - </field> - </record> - </data> + <data> + <!-- Add the SIREN and RC --> + <record model="ir.ui.view" id="view_partner_add"> + <field name="name">res.partner.form.siret</field> + <field name="model">res.partner</field> + <field name="inherit_id" ref="account.view_partner_property_form" /> + <field name="arch" type="xml"> + <page string="Accounting" position="inside"> + <group> + <group col="4"> + <field name="siret" colspan="4"/> + <field name="siren" class="oe_edit_only oe_inline" string="SIREN/NIC" colspan="3"/> + <field name="nic" class="oe_edit_only" nolabel="1"/> + </group> + <group> + <field name="company_registry" /> + </group> + </group> + </page> + </field> + </record> + </data> </openerp>
-- Mailing list: https://launchpad.net/~openerp-community-reviewer Post to : openerp-community-reviewer@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-community-reviewer More help : https://help.launchpad.net/ListHelp