diff --git a/partner_identification/README.rst b/partner_identification/README.rst new file mode 100644 index 000000000..5da05a116 --- /dev/null +++ b/partner_identification/README.rst @@ -0,0 +1,115 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================== +Partner Identification Numbers +============================== + +This module allows to manage all sort of identification numbers +and certificates which are assigned to a partner (company or individual) +and vary from country to country. + +* Commercial register +* VAT ID +* Fiscal ID's +* Membership numbers +* Driver license +* ... + + +Installation +============ + +No specific installation step required + + +Configuration +============= + +Configure all ID types you need in Sales > Configuration > Address Book > Partner ID Categories. +For example, we create a category 'Driver License': + +Name: + Name of this ID type. For example, 'Driver License' +Code: + Code, abbreviation or acronym of this ID type. For example, 'driver_license' +Python validation code: + Optional python code called to validate ID numbers of this ID type. + + +Usage +===== + +In partner form you will see another tab called 'ID Numbers'. You can add +any IDs to this partner, defining: + +Category: + ID type defined in configuration. For example, Driver License +ID Number: + The ID itself. For example, Driver License number of this person +Issued by: + Another partner, who issued this ID. For example, Traffic National Institution +Place of Issuance: + The place where the ID has been issued. For example the country for passports and visa +Valid from: + Issued date. For example, date when person approved his driving exam, 21/10/2009 +Valid until: + Expiration date. For example, date when person needs to renew his driver license, 21/10/2019 +Status: + ID status. For example new/to renew/expired +Notes: + Any further information related with this ID. For example, vehicle types this person can drive + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/ + + +Known issues / Roadmap +====================== + +* If you want to search a partner by ID you will use advance search form. + You can't search by issuer, valid dates, category or notes. + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + + +Credits +======= + +Contributors +------------ + +* Antonio Espinosa +* Denis Roussel +* Ferdinand Gassauer +* Gerhard Könighofer +* Laurent Mignon +* Yajo + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_identification/__init__.py b/partner_identification/__init__.py new file mode 100644 index 000000000..a77a6fcbc --- /dev/null +++ b/partner_identification/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/partner_identification/__openerp__.py b/partner_identification/__openerp__.py new file mode 100644 index 000000000..6c1c7ac43 --- /dev/null +++ b/partner_identification/__openerp__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# +# © 2004-2010 Tiny SPRL http://tiny.be +# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH +# http://www.camptocamp.at +# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# http://www.antiun.com +# Antonio Espinosa +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Partner Identification Numbers', + 'category': 'Customer Relationship Management', + 'version': '8.0.1.0.0', + 'data': [ + 'views/res_partner_id_category_view.xml', + 'views/res_partner_id_number_view.xml', + 'views/res_partner_view.xml', + 'security/ir.model.access.csv', + ], + 'author': 'ChriCar Beteiligungs- und Beratungs- GmbH, ' + 'Antiun Ingeniería S.L.', + 'Camptocamp,' + 'ACSONE SA/NV,' + 'Odoo Community Association (OCA)' + 'website': 'https://odoo-community.org/', + 'license': 'AGPL-3', + 'installable': True, +} diff --git a/partner_identification/i18n/de.po b/partner_identification/i18n/de.po new file mode 100644 index 000000000..4d4cdac84 --- /dev/null +++ b/partner_identification/i18n/de.po @@ -0,0 +1,139 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * chricar_partner_id_number +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-03-24 17:33+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Translate Toolkit 1.11.0\n" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,active:0 +#: field:res.partner.id_number,active:0 +msgid "Active" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,category_id:0 +msgid "Category" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,code:0 +msgid "Code" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,create_uid:0 +#: field:res.partner.id_number,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,create_date:0 +#: field:res.partner.id_number,create_date:0 +msgid "Created on" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,id:0 +#: field:res.partner.id_number,id:0 +msgid "ID" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,name:0 +msgid "ID Number" +msgstr "" + +#. module: chricar_partner_id_number +#: view:res.partner:chricar_partner_id_number.view_partner_form +msgid "ID Numbers" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,name:0 +msgid "ID name" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner,id_numbers:0 +msgid "Identification Numbers" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,partner_issued_id:0 +msgid "Issued by" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,date_issued:0 +msgid "Issued on" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,write_uid:0 +#: field:res.partner.id_number,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,write_date:0 +#: field:res.partner.id_number,write_date:0 +msgid "Last Updated on" +msgstr "" + +#. module: chricar_partner_id_number +#: view:res.partner.id_number:chricar_partner_id_number.view_partner_id_numbers_form +#: field:res.partner.id_number,comment:0 +msgid "Notes" +msgstr "" + +#. module: chricar_partner_id_number +#: model:ir.model,name:chricar_partner_id_number.model_res_partner +#: field:res.partner.id_number,partner_id:0 +msgid "Partner" +msgstr "" + +#. module: chricar_partner_id_number +#: model:ir.actions.act_window,name:chricar_partner_id_number.action_partner_id_category +#: model:ir.ui.menu,name:chricar_partner_id_number.menu_partner_id_category +msgid "Partner ID Categories" +msgstr "" + +#. module: chricar_partner_id_number +#: model:ir.actions.act_window,name:chricar_partner_id_number.action_partner_id_numbers_form +#: view:res.partner.id_number:chricar_partner_id_number.view_partner_id_numbers_form +#: view:res.partner.id_number:chricar_partner_id_number.view_partner_id_numbers_tree +msgid "Partner ID Numbers" +msgstr "" + +#. module: chricar_partner_id_number +#: view:res.partner.id_category:chricar_partner_id_number.view_partner_id_category_form +#: view:res.partner.id_category:chricar_partner_id_number.view_partner_id_category_tree +msgid "Partner Identification Categories" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,state:0 +msgid "State" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,valid_from:0 +msgid "Valid from" +msgstr "" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,valid_until:0 +msgid "Valid until" +msgstr "" diff --git a/partner_identification/i18n/es.po b/partner_identification/i18n/es.po new file mode 100644 index 000000000..fbe74e34c --- /dev/null +++ b/partner_identification/i18n/es.po @@ -0,0 +1,139 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * chricar_partner_id_number +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-03-24 17:33+0000\n" +"PO-Revision-Date: 2015-03-24 17:33+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: chricar_partner_id_number +#: field:res.partner.id_category,active:0 +#: field:res.partner.id_number,active:0 +msgid "Active" +msgstr "Activo" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,category_id:0 +msgid "Category" +msgstr "Categoría" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,code:0 +msgid "Code" +msgstr "Código" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,create_uid:0 +#: field:res.partner.id_number,create_uid:0 +msgid "Created by" +msgstr "Creado por" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,create_date:0 +#: field:res.partner.id_number,create_date:0 +msgid "Created on" +msgstr "Creado en" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,id:0 +#: field:res.partner.id_number,id:0 +msgid "ID" +msgstr "ID" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,name:0 +msgid "ID Number" +msgstr "Número ID" + +#. module: chricar_partner_id_number +#: view:res.partner:chricar_partner_id_number.view_partner_form +msgid "ID Numbers" +msgstr "Números ID" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,name:0 +msgid "ID name" +msgstr "Nombre ID" + +#. module: chricar_partner_id_number +#: field:res.partner,id_numbers:0 +msgid "Identification Numbers" +msgstr "Números de identificación" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,partner_issued_id:0 +msgid "Issued by" +msgstr "Emitido por" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,date_issued:0 +msgid "Issued on" +msgstr "Emitido en" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,write_uid:0 +#: field:res.partner.id_number,write_uid:0 +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: chricar_partner_id_number +#: field:res.partner.id_category,write_date:0 +#: field:res.partner.id_number,write_date:0 +msgid "Last Updated on" +msgstr "Última actualización en" + +#. module: chricar_partner_id_number +#: view:res.partner.id_number:chricar_partner_id_number.view_partner_id_numbers_form +#: field:res.partner.id_number,comment:0 +msgid "Notes" +msgstr "Notas" + +#. module: chricar_partner_id_number +#: model:ir.model,name:chricar_partner_id_number.model_res_partner +#: field:res.partner.id_number,partner_id:0 +msgid "Partner" +msgstr "Empresa" + +#. module: chricar_partner_id_number +#: model:ir.actions.act_window,name:chricar_partner_id_number.action_partner_id_category +#: model:ir.ui.menu,name:chricar_partner_id_number.menu_partner_id_category +msgid "Partner ID Categories" +msgstr "Tipos de identificadores" + +#. module: chricar_partner_id_number +#: model:ir.actions.act_window,name:chricar_partner_id_number.action_partner_id_numbers_form +#: view:res.partner.id_number:chricar_partner_id_number.view_partner_id_numbers_form +#: view:res.partner.id_number:chricar_partner_id_number.view_partner_id_numbers_tree +msgid "Partner ID Numbers" +msgstr "Identificadores de empresas" + +#. module: chricar_partner_id_number +#: view:res.partner.id_category:chricar_partner_id_number.view_partner_id_category_form +#: view:res.partner.id_category:chricar_partner_id_number.view_partner_id_category_tree +msgid "Partner Identification Categories" +msgstr "Tipos de identificadores" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,state:0 +msgid "State" +msgstr "Estado" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,valid_from:0 +msgid "Valid from" +msgstr "Válido desde" + +#. module: chricar_partner_id_number +#: field:res.partner.id_number,valid_until:0 +msgid "Valid until" +msgstr "Válido hasta" + diff --git a/partner_identification/i18n/fr.po b/partner_identification/i18n/fr.po new file mode 100644 index 000000000..ce367d5d7 --- /dev/null +++ b/partner_identification/i18n/fr.po @@ -0,0 +1,261 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-08-05 08:53+0000\n" +"PO-Revision-Date: 2016-08-05 08: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: partner_identification +#: code:addons/partner_identification/models/res_partner_id_category.py:24 +#, python-format +msgid "\n" +"# Python code. Use failed = True to specify that the id number is not valid.\n" +"# You can use the following variables :\n" +"# - self: browse_record of the current ID Category browse_record\n" +"# - id_number: browse_record of ID number to validate" +msgstr "\n" +"# Python code. Utilisez failed = True pour spécifier que l'identifiant n'est pas valide.\n" +"# Vous pouvez utiliser les variables suivantes :\n" +"# - self: browse_record de la catégorie d'identifiants actuelle browse_record\n" +"# - id_number: browse_record de l'identifiant à valider" + +#. module: partner_identification +#: code:addons/partner_identification/models/res_partner_id_category.py:70 +#, python-format +msgid "%s is not a valid %s identifier" +msgstr "%s n'est pas un identifiant valide %s" + +#. module: partner_identification +#: help:res.partner.id_category,code:0 +msgid "Abbreviation or acronym of this ID type. For example, 'driver_license'" +msgstr "Abbréviation ou acronyme pour ce type d'identifiant. Par exemple, 'driver_license'" + +#. module: partner_identification +#: field:res.partner.id_category,active:0 +#: field:res.partner.id_number,active:0 +msgid "Active" +msgstr "Actif" + +#. module: partner_identification +#: help:res.partner.id_number,partner_issued_id:0 +msgid "Another partner, who issued this ID. For example, Traffic National Institution" +msgstr "Un autre partenaire, qui a émis cet identifiant. Par exemple, Traffic National Institution" + +#. module: partner_identification +#: field:res.partner.id_number,category_id:0 +msgid "Category" +msgstr "Catégorie" + +#. module: partner_identification +#: field:res.partner.id_category,code:0 +msgid "Code" +msgstr "Code" + +#. module: partner_identification +#: field:res.partner.id_category,create_uid:0 +#: field:res.partner.id_number,create_uid:0 +msgid "Created by" +msgstr "Créé par" + +#. module: partner_identification +#: field:res.partner.id_category,create_date:0 +#: field:res.partner.id_number,create_date:0 +msgid "Created on" +msgstr "Créé le" + +#. module: partner_identification +#: field:res.partner.id_category,display_name:0 +#: field:res.partner.id_number,display_name:0 +msgid "Display Name" +msgstr "Nom" + +#. module: partner_identification +#: code:addons/partner_identification/models/res_partner_id_category.py:66 +#, python-format +msgid "Error when evaluating the id_category validation code::\n" +" %s \n" +"(%s)" +msgstr "Erreur lors de l'évaluation du code de validation de la catégorie::\n" +" %s \n" +"(%s)" + +#. module: partner_identification +#: help:res.partner.id_number,valid_until:0 +msgid "Expiration date. For example, date when person needs to renew his driver license, 21/10/2019" +msgstr "Date d'expiration. Par exemple, la date à laquelle la personne doit renouveler son permis de conduire, 21/10/2019" + +#. module: partner_identification +#: selection:res.partner.id_number,status:0 +msgid "Expired" +msgstr "Expiré" + +#. module: partner_identification +#: field:res.partner.id_category,id:0 +#: field:res.partner.id_number,id:0 +msgid "ID" +msgstr "Identifiant" + +#. module: partner_identification +#: field:res.partner.id_number,name:0 +msgid "ID Number" +msgstr "Identifiant" + +#. module: partner_identification +#: view:res.partner:partner_identification.view_partner_form +msgid "ID Numbers" +msgstr "Identifiants" + +#. module: partner_identification +#: field:res.partner.id_category,name:0 +msgid "ID name" +msgstr "Nom de l'identifiant" + +#. module: partner_identification +#: help:res.partner.id_number,category_id:0 +msgid "ID type defined in configuration. For example, Driver License" +msgstr "Type d'identifiant défini dans la configuration. Par exemple, Permis de conduire" + +#. module: partner_identification +#: field:res.partner,id_numbers:0 +msgid "Identification Numbers" +msgstr "Numéros d'identification" + +#. module: partner_identification +#: field:res.partner.id_number,partner_issued_id:0 +msgid "Issued by" +msgstr "Émis par" + +#. module: partner_identification +#: help:res.partner.id_number,date_issued:0 +msgid "Issued date. For example, date when person approved his driving exam, 21/10/2009" +msgstr "Date d'émission. Par exemple, la date à laquelle la personne a réussi son permis de conduire, 21/10/2009" + +#. module: partner_identification +#: field:res.partner.id_number,date_issued:0 +msgid "Issued on" +msgstr "Émis le" + +#. module: partner_identification +#: field:res.partner.id_category,__last_update:0 +#: field:res.partner.id_number,__last_update:0 +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: partner_identification +#: field:res.partner.id_category,write_uid:0 +#: field:res.partner.id_number,write_uid:0 +msgid "Last Updated by" +msgstr "Dernière modification par" + +#. module: partner_identification +#: field:res.partner.id_category,write_date:0 +#: field:res.partner.id_number,write_date:0 +msgid "Last Updated on" +msgstr "Dernière modification le" + +#. module: partner_identification +#: help:res.partner.id_category,name:0 +msgid "Name of this ID type. For example, 'Driver License'" +msgstr "Nom de ce type d'identifiant. Par exemple, 'Permis de conduire'" + +#. module: partner_identification +#: selection:res.partner.id_number,status:0 +msgid "New" +msgstr "Nouveau" + +#. module: partner_identification +#: view:res.partner.id_number:partner_identification.view_partner_id_numbers_form +#: field:res.partner.id_number,comment:0 +msgid "Notes" +msgstr "Notes" + +#. module: partner_identification +#: model:ir.model,name:partner_identification.model_res_partner +#: field:res.partner.id_number,partner_id:0 +msgid "Partner" +msgstr "Partenaire" + +#. module: partner_identification +#: model:ir.actions.act_window,name:partner_identification.action_partner_id_category +#: model:ir.ui.menu,name:partner_identification.menu_partner_id_category +msgid "Partner ID Categories" +msgstr "Catégories d'identifiant partenaire" + +#. module: partner_identification +#: model:ir.actions.act_window,name:partner_identification.action_partner_id_numbers_form +#: view:res.partner.id_number:partner_identification.view_partner_id_numbers_form +#: view:res.partner.id_number:partner_identification.view_partner_id_numbers_tree +msgid "Partner ID Numbers" +msgstr "Numéros d'identification" + +#. module: partner_identification +#: view:res.partner.id_category:partner_identification.view_partner_id_category_form +#: view:res.partner.id_category:partner_identification.view_partner_id_category_tree +msgid "Partner Identification Categories" +msgstr "Catégories d'identifiants" + +#. module: partner_identification +#: field:res.partner.id_number,place_issuance:0 +msgid "Place of Issuance" +msgstr "Lieu d'émission" + +#. module: partner_identification +#: help:res.partner.id_category,validation_code:0 +msgid "Python code called to validate an id number." +msgstr "Code python appelé pour valider le numéro d'identification." + +#. module: partner_identification +#: field:res.partner.id_category,validation_code:0 +msgid "Python validation code" +msgstr "Code python de validation" + +#. module: partner_identification +#: selection:res.partner.id_number,status:0 +msgid "Running" +msgstr "En cours" + +#. module: partner_identification +#: field:res.partner.id_number,status:0 +msgid "Status" +msgstr "Statut" + +#. module: partner_identification +#: help:res.partner.id_number,name:0 +msgid "The ID itself. For example, Driver License number of this person" +msgstr "L'identifiant lui-même. Par exemple, le numéro de permis de conduire de cette personne" + +#. module: partner_identification +#: help:res.partner.id_number,place_issuance:0 +msgid "The place where the ID has been issued. For example the country for passports and visa" +msgstr "Le lieu d'émission de l'identifiant. Par exemple le pays pour les passeports et les visas" + +#. module: partner_identification +#: selection:res.partner.id_number,status:0 +msgid "To Renew" +msgstr "A renouveler" + +#. module: partner_identification +#: field:res.partner.id_number,valid_from:0 +msgid "Valid from" +msgstr "Valide depuis" + +#. module: partner_identification +#: field:res.partner.id_number,valid_until:0 +msgid "Valid until" +msgstr "Valide jusque" + +#. module: partner_identification +#: help:res.partner.id_number,valid_from:0 +msgid "Validation period stating date." +msgstr "La date de début de la période de validation." + diff --git a/partner_identification/models/__init__.py b/partner_identification/models/__init__.py new file mode 100644 index 000000000..699c4c59d --- /dev/null +++ b/partner_identification/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import res_partner_id_number +from . import res_partner_id_category +from . import res_partner diff --git a/partner_identification/models/res_partner.py b/partner_identification/models/res_partner.py new file mode 100644 index 000000000..63b8fcd42 --- /dev/null +++ b/partner_identification/models/res_partner.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# +# © 2004-2010 Tiny SPRL http://tiny.be +# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH +# http://www.camptocamp.at +# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# http://www.antiun.com +# Antonio Espinosa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models, fields + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + id_numbers = fields.One2many( + comodel_name='res.partner.id_number', inverse_name='partner_id', + string="Identification Numbers") diff --git a/partner_identification/models/res_partner_id_category.py b/partner_identification/models/res_partner_id_category.py new file mode 100644 index 000000000..01f38d050 --- /dev/null +++ b/partner_identification/models/res_partner_id_category.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# +# © 2004-2010 Tiny SPRL http://tiny.be +# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH +# http://www.camptocamp.at +# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# http://www.antiun.com +# Antonio Espinosa +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from openerp import api, models, fields +from openerp.exceptions import ValidationError, Warning as UserError +from openerp.tools.safe_eval import safe_eval +from openerp.tools.translate import _ + + +class ResPartnerIdCategory(models.Model): + _name = "res.partner.id_category" + _order = "name" + + def _default_validation_code(self): + return _("\n# Python code. Use failed = True to specify that the id " + "number is not valid.\n" + "# You can use the following variables :\n" + "# - self: browse_record of the current ID Category " + "browse_record\n" + "# - id_number: browse_record of ID number to validate") + + code = fields.Char( + string="Code", size=16, required=True, + help="Abbreviation or acronym of this ID type. For example, " + "'driver_license'") + name = fields.Char( + string="ID name", required=True, translate=True, + help="Name of this ID type. For example, 'Driver License'") + active = fields.Boolean(string="Active", default=True) + validation_code = fields.Text( + 'Python validation code', + help="Python code called to validate an id number.", + default=_default_validation_code) + + @api.multi + def _validation_eval_context(self, id_number): + self.ensure_one() + return {'self': self, + 'id_number': id_number, + } + + @api.multi + def validate_id_number(self, id_number): + """Validate the given ID number + The method raises an openerp.exceptions.ValidationError if the eval of + python validation code fails + """ + self.ensure_one() + eval_context = self._validation_eval_context(id_number) + try: + safe_eval(self.validation_code, + eval_context, + mode='exec', + nocopy=True) + except Exception as e: + raise UserError( + _('Error when evaluating the id_category validation code:' + ':\n %s \n(%s)') % (self.name, e)) + if eval_context.get('failed', False): + raise ValidationError( + _("%s is not a valid %s identifier") % ( + id_number.name, self.name)) diff --git a/partner_identification/models/res_partner_id_number.py b/partner_identification/models/res_partner_id_number.py new file mode 100644 index 000000000..a8859cec7 --- /dev/null +++ b/partner_identification/models/res_partner_id_number.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# +# © 2004-2010 Tiny SPRL http://tiny.be +# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH +# http://www.camptocamp.at +# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# http://www.antiun.com +# Antonio Espinosa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from openerp import api, models, fields + + +class ResPartnerIdNumber(models.Model): + _name = "res.partner.id_number" + _order = "name" + + @api.constrains('name', 'category_id') + def validate_id_number(self): + self.category_id.validate_id_number(self) + + name = fields.Char( + string="ID Number", required=True, + help="The ID itself. For example, Driver License number of this " + "person") + category_id = fields.Many2one( + string="Category", required=True, + comodel_name='res.partner.id_category', + help="ID type defined in configuration. For example, Driver License") + partner_id = fields.Many2one(string="Partner", required=True, + comodel_name='res.partner', + ondelete='cascade') + partner_issued_id = fields.Many2one( + string="Issued by", comodel_name='res.partner', + help="Another partner, who issued this ID. For example, Traffic " + "National Institution") + place_issuance = fields.Char( + string="Place of Issuance", + help="The place where the ID has been issued. For example the country " + "for passports and visa") + date_issued = fields.Date( + string="Issued on", + help="Issued date. For example, date when person approved his driving " + "exam, 21/10/2009") + valid_from = fields.Date( + string="Valid from", + help="Validation period stating date.") + valid_until = fields.Date( + string="Valid until", + help="Expiration date. For example, date when person needs to renew " + "his driver license, 21/10/2019") + comment = fields.Text(string="Notes") + status = fields.Selection( + [('draft', 'New'), + ('open', 'Running'), + ('pending', 'To Renew'), + ('close', 'Expired')]) + active = fields.Boolean(string="Active", default=True) diff --git a/partner_identification/security/ir.model.access.csv b/partner_identification/security/ir.model.access.csv new file mode 100644 index 000000000..7e69931ea --- /dev/null +++ b/partner_identification/security/ir.model.access.csv @@ -0,0 +1,5 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_res_partner_id_number_group_user","res.partner.id_number","model_res_partner_id_number","base.group_user",1,0,0,0 +"access_res_partner_id_number_group_partner_manager","res.partner.id_number","model_res_partner_id_number","base.group_partner_manager",1,1,1,1 +"access_res_partner_id_category_group_user","res.partner.id_category","model_res_partner_id_category","base.group_user",1,0,0,0 +"access_res_partner_id_category_group_partner_manager","res.partner.id_category","model_res_partner_id_category","base.group_partner_manager",1,1,1,1 diff --git a/partner_identification/tests/__init__.py b/partner_identification/tests/__init__.py new file mode 100644 index 000000000..f848b5bcf --- /dev/null +++ b/partner_identification/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import test_partner_identification diff --git a/partner_identification/tests/test_partner_identification.py b/partner_identification/tests/test_partner_identification.py new file mode 100644 index 000000000..9d46f7642 --- /dev/null +++ b/partner_identification/tests/test_partner_identification.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from psycopg2._psycopg import IntegrityError +import openerp.tests.common as common +from openerp.exceptions import ValidationError + + +class TestPartnerIdentificationBase(common.TransactionCase): + + def test_base_functionalities(self): + """Dummy CRUD test + """ + partner_id_category = self.env['res.partner.id_category'].create({ + 'code': 'id_code', + 'name': 'id_name', + }) + self.assertEqual(partner_id_category.name, 'id_name') + self.assertEqual(partner_id_category.code, 'id_code') + + partner_1 = self.env.ref('base.res_partner_1') + self.assertEquals(len(partner_1.id_numbers), 0) + # create without required category + with self.assertRaises(IntegrityError), self.cr.savepoint(): + partner_1.write({'id_numbers': [(0, 0, { + 'name': '1234', + })]}) + # successful creation + partner_1.write({'id_numbers': [(0, 0, { + 'name': '1234', + 'category_id': partner_id_category.id + })]}) + self.assertEquals(len(partner_1.id_numbers), 1) + self.assertEquals(partner_1.id_numbers.name, '1234') + # delete + partner_1.write({'id_numbers': [(5, 0, 0)]}) + self.assertEquals(len(partner_1.id_numbers), 0) + + +class TestPartnerCategoryValidation(common.TransactionCase): + + def test_partner_id_number_validation(self): + partner_id_category = self.env['res.partner.id_category'].create({ + 'code': 'id_code', + 'name': 'id_name', + 'validation_code': """ +if id_number.name != '1234': + failed = True +""" + }) + partner_1 = self.env.ref('base.res_partner_1') + with self.assertRaises(ValidationError), self.cr.savepoint(): + partner_1.write({'id_numbers': [(0, 0, { + 'name': '01234', + 'category_id': partner_id_category.id + })]}) + partner_1.write({'id_numbers': [(0, 0, { + 'name': '1234', + 'category_id': partner_id_category.id + })]}) + self.assertEquals(len(partner_1.id_numbers), 1) + self.assertEquals(partner_1.id_numbers.name, '1234') + + partner_id_category2 = self.env['res.partner.id_category'].create({ + 'code': 'id_code2', + 'name': 'id_name2', + 'validation_code': """ +if id_number.name != '1235': + failed = True +"""}) + # check that the constrains is also checked when we change the + # associated category + with self.assertRaises(ValidationError), self.cr.savepoint(): + partner_1.id_numbers.write({ + 'category_id': partner_id_category2.id + }) + + def test_bad_calidation_code(self): + partner_id_category = self.env['res.partner.id_category'].create({ + 'code': 'id_code', + 'name': 'id_name', + 'validation_code': """ +if id_number.name != '1234' # missing : + failed = True +""" + }) + partner_1 = self.env.ref('base.res_partner_1') + with self.assertRaises(ValidationError): + partner_1.write({'id_numbers': [(0, 0, { + 'name': '1234', + 'category_id': partner_id_category.id + })]}) diff --git a/partner_identification/views/res_partner_id_category_view.xml b/partner_identification/views/res_partner_id_category_view.xml new file mode 100644 index 000000000..dca4e6dfd --- /dev/null +++ b/partner_identification/views/res_partner_id_category_view.xml @@ -0,0 +1,44 @@ + + + + + + + res.partner.id_category.form + res.partner.id_category + form + +
+ + + + +
+
+
+ + + res.partner.id_category.tree + res.partner.id_category + tree + + + + + + + + + + Partner ID Categories + res.partner.id_category + form + tree,form + + + + +
+
diff --git a/partner_identification/views/res_partner_id_number_view.xml b/partner_identification/views/res_partner_id_number_view.xml new file mode 100644 index 000000000..00f325ff8 --- /dev/null +++ b/partner_identification/views/res_partner_id_number_view.xml @@ -0,0 +1,52 @@ + + + + + + res.partner.id_number.form + res.partner.id_number + form + +
+ + + + + + + + + + + + + + +
+ + + res.partner.id_number.tree + res.partner.id_number + tree + + + + + + + + + + + + + + + Partner ID Numbers + res.partner.id_number + form + tree,form + + +
+
diff --git a/partner_identification/views/res_partner_view.xml b/partner_identification/views/res_partner_view.xml new file mode 100644 index 000000000..eddea27a9 --- /dev/null +++ b/partner_identification/views/res_partner_view.xml @@ -0,0 +1,23 @@ + + + + + + + res.partner.form.id_number + res.partner + + + + + + + + + + + + + +