Joao Alfredo Gama Batista has proposed merging lp:~savoirfairelinux-openerp/openerp-canada/openerp-canada_res_partner_attributes_add_NEQ into lp:openerp-canada.
Requested reviews: Joao Alfredo Gama Batista (joao-gama): code review. no test Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) For more details, see: https://code.launchpad.net/~savoirfairelinux-openerp/openerp-canada/openerp-canada_res_partner_attributes_add_NEQ/+merge/175921 Add SIN, BN, and NEQ numbers. This is a resubmit with a SIN validation and a few translation improvements. -- https://code.launchpad.net/~savoirfairelinux-openerp/openerp-canada/openerp-canada_res_partner_attributes_add_NEQ/+merge/175921 Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/openerp-canada/openerp-canada_res_partner_attributes_add_NEQ.
=== added directory 'res_partner_attributes_add_BN' === added file 'res_partner_attributes_add_BN/__init__.py' --- res_partner_attributes_add_BN/__init__.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_BN/__init__.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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 res_partner_attributes_add_BN + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added file 'res_partner_attributes_add_BN/__openerp__.py' --- res_partner_attributes_add_BN/__openerp__.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_BN/__openerp__.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,39 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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' : 'Business identification Number in Canada (BN/NE)', + 'version' : '1.0', + "author" : "Savoir-faire Linux ([email protected])", + "website" : "http://www.savoirfairelinux.com", + 'license': 'AGPL-3', + 'category' : 'Localisation/Canada', + 'depends' : ['base'], + 'description': """ +Add the Business identification Number (BN/NE) to the partner form. +""", + 'auto_install': False, + 'installable': True, + 'data' : ['res_partner_attributes_add_BN_view.xml'] +} + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added directory 'res_partner_attributes_add_BN/i18n' === added file 'res_partner_attributes_add_BN/i18n/fr.po' --- res_partner_attributes_add_BN/i18n/fr.po 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_BN/i18n/fr.po 2013-07-19 18:50:42 +0000 @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * res_partner_attributes_add_BN +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-19 18:29+0000\n" +"PO-Revision-Date: 2013-07-19 14:32-0400\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: res_partner_attributes_add_BN +#: model:ir.model,name:res_partner_attributes_add_BN.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: res_partner_attributes_add_BN +#: field:res.partner,ne:0 +msgid "BN" +msgstr "NE" + +#. module: res_partner_attributes_add_BN +#: help:res.partner,ne:0 +msgid "Canada Business identification Number (9 digits)" +msgstr "Numéro d'Entreprise du Canada (9 chiffres)" + === added file 'res_partner_attributes_add_BN/i18n/res_partner_attributes_add_BN.pot' --- res_partner_attributes_add_BN/i18n/res_partner_attributes_add_BN.pot 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_BN/i18n/res_partner_attributes_add_BN.pot 2013-07-19 18:50:42 +0000 @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * res_partner_attributes_add_NE +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-11 14:53+0000\n" +"PO-Revision-Date: 2013-07-11 14:53+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: res_partner_attributes_add_NE +#: model:ir.model,name:res_partner_attributes_add_NE.model_res_partner +msgid "Partner" +msgstr "" + +#. module: res_partner_attributes_add_NE +#: help:res.partner,ne:0 +msgid "Canada Business identification Number (9 digits)" +msgstr "" + +#. module: res_partner_attributes_add_NE +#: field:res.partner,ne:0 +msgid "NE" +msgstr "" + === added file 'res_partner_attributes_add_BN/res_partner_attributes_add_BN.py' --- res_partner_attributes_add_BN/res_partner_attributes_add_BN.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_BN/res_partner_attributes_add_BN.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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 +from openerp.tools.translate import _ + + +class res_partner(orm.Model): + _name = 'res.partner' + _inherit = 'res.partner' + _columns = { + 'ne': fields.float('BN', digits=(9, 0), + help="Canada Business identification Number (9 digits)"), + } + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added file 'res_partner_attributes_add_BN/res_partner_attributes_add_BN_view.xml' --- res_partner_attributes_add_BN/res_partner_attributes_add_BN_view.xml 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_BN/res_partner_attributes_add_BN_view.xml 2013-07-19 18:50:42 +0000 @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record model="ir.ui.view" id="res_partner_attributes_add_NE_form_view"> + <field name="name">res_partner_attributes_add_NE</field> + <field name="model">res.partner</field> + <field name="inherit_id" ref="base.view_partner_form"/> + <field name="arch" type="xml"> + <field name="email" position="after"> + <field name="ne" attrs="{'invisible': [('is_company','=', False)]}"/> + </field> + </field> + </record> + + </data> +</openerp> === added directory 'res_partner_attributes_add_NEQ' === added file 'res_partner_attributes_add_NEQ/__init__.py' --- res_partner_attributes_add_NEQ/__init__.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_NEQ/__init__.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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 res_partner_attributes_add_NEQ + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added file 'res_partner_attributes_add_NEQ/__openerp__.py' --- res_partner_attributes_add_NEQ/__openerp__.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_NEQ/__openerp__.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,39 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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' : 'Quebec Enterprise Number (NEQ)', + 'version' : '1.1', + "author" : "Savoir-faire Linux ([email protected])", + "website" : "http://www.savoirfairelinux.com", + 'license': 'AGPL-3', + 'category' : 'Localisation/Canada', + 'depends' : ['base'], + 'description': """ +Add the Quebec Enterprise Number (NEQ) to the partner form. +""", + 'auto_install': False, + 'installable': True, + 'data' : ['res_partner_attributes_add_NEQ_view.xml'] +} + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added directory 'res_partner_attributes_add_NEQ/i18n' === added file 'res_partner_attributes_add_NEQ/i18n/res_partner_attributes_add_NEQ.mo' Binary files res_partner_attributes_add_NEQ/i18n/res_partner_attributes_add_NEQ.mo 1970-01-01 00:00:00 +0000 and res_partner_attributes_add_NEQ/i18n/res_partner_attributes_add_NEQ.mo 2013-07-19 18:50:42 +0000 differ === added file 'res_partner_attributes_add_NEQ/i18n/res_partner_attributes_add_NEQ.pot' --- res_partner_attributes_add_NEQ/i18n/res_partner_attributes_add_NEQ.pot 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_NEQ/i18n/res_partner_attributes_add_NEQ.pot 2013-07-19 18:50:42 +0000 @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * res_partner_attributes_add_NEQ +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-11 14:53+0000\n" +"PO-Revision-Date: 2013-07-11 10:58-0500\n" +"Last-Translator: Marc Cassuto <[email protected]>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: res_partner_attributes_add_NEQ +#: model:ir.model,name:res_partner_attributes_add_NEQ.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: res_partner_attributes_add_NEQ +#: help:res.partner,neq:0 +msgid "Quebec Enterprise Number (10 digits)" +msgstr "Numéro d'Entreprise du Quebec (10 chiffres)" + +#. module: res_partner_attributes_add_NEQ +#: field:res.partner,neq:0 +msgid "NEQ" +msgstr "NEQ" + === added file 'res_partner_attributes_add_NEQ/res_partner_attributes_add_NEQ.py' --- res_partner_attributes_add_NEQ/res_partner_attributes_add_NEQ.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_NEQ/res_partner_attributes_add_NEQ.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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 +from openerp.tools.translate import _ + +class res_partner(orm.Model): + _name = 'res.partner' + _inherit = 'res.partner' + _columns = { + 'neq': fields.float('NEQ', digits=(10,0), help="Quebec Enterprise Number (10 digits)"), + } + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added file 'res_partner_attributes_add_NEQ/res_partner_attributes_add_NEQ_view.xml' --- res_partner_attributes_add_NEQ/res_partner_attributes_add_NEQ_view.xml 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_NEQ/res_partner_attributes_add_NEQ_view.xml 2013-07-19 18:50:42 +0000 @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record model="ir.ui.view" id="res_partner_attributes_add_NEQ_form_view"> + <field name="name">res_partner_attributes_add_NEQ</field> + <field name="model">res.partner</field> + <field name="inherit_id" ref="base.view_partner_form"/> + <field name="arch" type="xml"> + <field name="website" position="after"> + <field name="neq" attrs="{'invisible': [('is_company','=', False)]}"/> + </field> + </field> + </record> + </data> +</openerp> === added directory 'res_partner_attributes_add_SIN' === added file 'res_partner_attributes_add_SIN/__init__.py' --- res_partner_attributes_add_SIN/__init__.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_SIN/__init__.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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 res_partner_attributes_add_SIN + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added file 'res_partner_attributes_add_SIN/__openerp__.py' --- res_partner_attributes_add_SIN/__openerp__.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_SIN/__openerp__.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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' : 'Canada Social Insurance Number (SIN/NAS)', + 'version' : '1.0', + "author" : "Savoir-faire Linux ([email protected])", + "website" : "http://www.savoirfairelinux.com", + 'license': 'AGPL-3', + 'category' : 'Localisation/Canada', + 'depends' : ['base'], + 'description': """ +Add the Social Insurance Number (SIN/NAS) to the partner form. +""", + 'auto_install': False, + 'installable': True, + 'data' : ['res_partner_attributes_add_SIN_view.xml'] +} + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added directory 'res_partner_attributes_add_SIN/i18n' === added file 'res_partner_attributes_add_SIN/i18n/fr.mo' Binary files res_partner_attributes_add_SIN/i18n/fr.mo 1970-01-01 00:00:00 +0000 and res_partner_attributes_add_SIN/i18n/fr.mo 2013-07-19 18:50:42 +0000 differ === added file 'res_partner_attributes_add_SIN/i18n/fr.po' --- res_partner_attributes_add_SIN/i18n/fr.po 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_SIN/i18n/fr.po 2013-07-19 18:50:42 +0000 @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * res_partner_attributes_add_NAS +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-19 16:41+0000\n" +"PO-Revision-Date: 2013-07-19 13:14-0400\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: res_partner_attributes_add_NAS +#: model:ir.model,name:res_partner_attributes_add_NAS.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: res_partner_attributes_add_NAS +#: help:res.partner,nas:0 +msgid "Social Insurance Number (9 digits)" +msgstr "Numéro d'Assurance Sociale (9 chiffres)" + +#. module: res_partner_attributes_add_NAS +#: field:res.partner,nas:0 +msgid "SIN" +msgstr "NAS" + === added file 'res_partner_attributes_add_SIN/i18n/res_partner_attributes_add_SIN.pot' --- res_partner_attributes_add_SIN/i18n/res_partner_attributes_add_SIN.pot 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_SIN/i18n/res_partner_attributes_add_SIN.pot 2013-07-19 18:50:42 +0000 @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * res_partner_attributes_add_NAS +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-11 14:53+0000\n" +"PO-Revision-Date: 2013-07-11 14:53+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: res_partner_attributes_add_NAS +#: field:res.partner,nas:0 +msgid "NAS" +msgstr "" + +#. module: res_partner_attributes_add_NAS +#: help:res.partner,nas:0 +msgid "Social Insurance Number (9 digits)" +msgstr "" + +#. module: res_partner_attributes_add_NAS +#: model:ir.model,name:res_partner_attributes_add_NAS.model_res_partner +msgid "Partner" +msgstr "" + === added file 'res_partner_attributes_add_SIN/res_partner_attributes_add_SIN.py' --- res_partner_attributes_add_SIN/res_partner_attributes_add_SIN.py 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_SIN/res_partner_attributes_add_SIN.py 2013-07-19 18:50:42 +0000 @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>). +# +# 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 +from openerp.tools.translate import _ + + +class res_partner(orm.Model): + _name = 'res.partner' + _inherit = 'res.partner' + + def onchange_nas(self, cr, uid, ids, nas): + ret = {'value': 0} + + def digits_of(n): + return [int(d) for d in str(n)] + + def luhn_checksum(nas): + digits = digits_of(nas) + odd_digits = digits[-1::-2] + even_digits = digits[-2::-2] + checksum = 0 + checksum += sum(odd_digits) + for d in even_digits: + checksum += sum(digits_of(d * 2)) + return checksum % 10 + + def is_luhn_valid(nas): + return luhn_checksum(nas) == 0 + + if is_luhn_valid(nas): + ret['value'] = nas + else: + ret['value'] = 0 + ret['warning'] = { + 'title': 'Error', + 'message': _('The number provided is not a valid SIN number !') + } + return ret + + _columns = { + 'nas': fields.float('SIN', digits=(9, 0), + help="Social Insurance Number (9 digits)"), + } + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === added file 'res_partner_attributes_add_SIN/res_partner_attributes_add_SIN_view.xml' --- res_partner_attributes_add_SIN/res_partner_attributes_add_SIN_view.xml 1970-01-01 00:00:00 +0000 +++ res_partner_attributes_add_SIN/res_partner_attributes_add_SIN_view.xml 2013-07-19 18:50:42 +0000 @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record model="ir.ui.view" id="res_partner_attributes_add_NAS_form_view"> + <field name="name">res_partner_attributes_add_NAS</field> + <field name="model">res.partner</field> + <field name="inherit_id" ref="base.view_partner_form"/> + <field name="arch" type="xml"> + <field name="website" position="after"> + <field name="nas" on_change="onchange_nas(nas)" attrs="{'invisible': [('is_company','=', True)]}"/> + </field> + </field> + </record> + </data> +</openerp>
-- Mailing list: https://launchpad.net/~savoirfairelinux-openerp Post to : [email protected] Unsubscribe : https://launchpad.net/~savoirfairelinux-openerp More help : https://help.launchpad.net/ListHelp

