Browse Source
Merge pull request #255 from acsone/9.0-add_partner_identifiers-lmi
Merge pull request #255 from acsone/9.0-add_partner_identifiers-lmi
9.0 add partner identifierspull/256/head
Eric Caudal
9 years ago
15 changed files with 794 additions and 0 deletions
-
115partner_identification/README.rst
-
4partner_identification/__init__.py
-
29partner_identification/__openerp__.py
-
139partner_identification/i18n/de.po
-
139partner_identification/i18n/es.po
-
6partner_identification/models/__init__.py
-
19partner_identification/models/res_partner.py
-
71partner_identification/models/res_partner_id_category.py
-
58partner_identification/models/res_partner_id_number.py
-
5partner_identification/security/ir.model.access.csv
-
3partner_identification/tests/__init__.py
-
87partner_identification/tests/test_partner_identification.py
-
44partner_identification/views/res_partner_id_category_view.xml
-
52partner_identification/views/res_partner_id_number_view.xml
-
23partner_identification/views/res_partner_view.xml
@ -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/134/9.0 |
|||
|
|||
|
|||
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 |
|||
<https://github.com/OCA/partner_contact/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 |
|||
<https://github.com/OCA/ |
|||
partner_contact/issues/new?body=module:%20 |
|||
partner_identifiers%0Aversion:%20 |
|||
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
|
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Antonio Espinosa <antonioea@antiun.com> |
|||
* Ferdinand Gassauer <office@chrcar.at> |
|||
* Gerhard Könighofer <gerhard.koenighofer@swing-system.com> |
|||
* Laurent Mignon <laurent.mignon@acsone.eu> |
|||
* Yajo <Yajo@users.noreply.github.com> |
|||
|
|||
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. |
|||
|
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import models |
@ -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 <antonioea@antiun.com> |
|||
# © 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
{ |
|||
'name': 'Partner Identification Numbers', |
|||
'category': 'Customer Relationship Management', |
|||
'version': '9.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, |
|||
} |
@ -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 <EMAIL@ADDRESS>\n" |
|||
"Language-Team: LANGUAGE <LL@li.org>\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 "" |
@ -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" |
|||
|
@ -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 |
@ -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 <antonioea@antiun.com> |
|||
# 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") |
@ -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 <antonioea@antiun.com> |
|||
# © 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
|
|||
from openerp import api, models, fields |
|||
from openerp.exceptions import ValidationError, 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)) |
@ -0,0 +1,58 @@ |
|||
# -*- 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 <antonioea@antiun.com> |
|||
# 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') |
|||
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) |
@ -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 |
@ -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 |
@ -0,0 +1,87 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 ACSONE SA/NV (<http://acsone.eu>) |
|||
# 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) |
|||
with self.assertRaises(IntegrityError), self.cr.savepoint(): |
|||
partner_1.write({'id_numbers': [(0, 0, { |
|||
'name': '1234', |
|||
})]}) |
|||
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') |
|||
|
|||
|
|||
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 |
|||
})]}) |
@ -0,0 +1,44 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<!-- Partner Identification Number Categories --> |
|||
<record id="view_partner_id_category_form" model="ir.ui.view"> |
|||
<field name="name">res.partner.id_category.form</field> |
|||
<field name="model">res.partner.id_category</field> |
|||
<field name="type">form</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Partner Identification Categories"> |
|||
<group> |
|||
<field name="name" /> |
|||
<field name="code" /> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="view_partner_id_category_tree" model="ir.ui.view"> |
|||
<field name="name">res.partner.id_category.tree</field> |
|||
<field name="model">res.partner.id_category</field> |
|||
<field name="type">tree</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Partner Identification Categories"> |
|||
<field name="name"/> |
|||
<field name="code"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_partner_id_category" model="ir.actions.act_window"> |
|||
<field name="name">Partner ID Categories</field> |
|||
<field name="res_model">res.partner.id_category</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
|
|||
<menuitem action="action_partner_id_category" |
|||
id="menu_partner_id_category" |
|||
parent="base.menu_config_address_book"/> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,52 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="view_partner_id_numbers_form" model="ir.ui.view"> |
|||
<field name="name">res.partner.id_number.form</field> |
|||
<field name="model">res.partner.id_number</field> |
|||
<field name="type">form</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Partner ID Numbers"> |
|||
<group> |
|||
<field name="category_id" /> |
|||
<field name="name" /> |
|||
<field name="partner_issued_id" /> |
|||
<field name="date_issued" /> |
|||
<field name="place_issuance" /> |
|||
<field name="valid_from" /> |
|||
<field name="valid_until" /> |
|||
<field name="status" /> |
|||
</group> |
|||
<separator colspan="4" string="Notes"/> |
|||
<field name="comment" colspan="4" nolabel="1"/> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="view_partner_id_numbers_tree" model="ir.ui.view"> |
|||
<field name="name">res.partner.id_number.tree</field> |
|||
<field name="model">res.partner.id_number</field> |
|||
<field name="type">tree</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Partner ID Numbers"> |
|||
<field name="category_id" /> |
|||
<field name="name" /> |
|||
<field name="partner_issued_id" /> |
|||
<field name="date_issued" /> |
|||
<field name="valid_from" /> |
|||
<field name="valid_until" /> |
|||
<field name="status" /> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="action_partner_id_numbers_form" model="ir.actions.act_window"> |
|||
<field name="name">Partner ID Numbers</field> |
|||
<field name="res_model">res.partner.id_number</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<!-- Modification of Partner - Adding Tab for Idenification Numbers --> |
|||
<record model="ir.ui.view" id="view_partner_form"> |
|||
<field name="name">res.partner.form.id_number</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_form"/> |
|||
<field name="priority" eval="10"/> |
|||
<field name="arch" type="xml"> |
|||
<page name='sales_purchases' position="after"> |
|||
<page string="ID Numbers" name="id_numbers"> |
|||
<field name="id_numbers" colspan="4" nolabel="1" |
|||
widget="one2many_list"/> |
|||
</page> |
|||
</page> |
|||
</field> |
|||
</record> |
|||
|
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue