Browse Source

[11.0][MIG] partner_identification

pull/644/head
Simone Orsi 7 years ago
committed by tarteo
parent
commit
707a05fa90
  1. 27
      partner_identification/README.rst
  2. 15
      partner_identification/__manifest__.py
  3. 6
      partner_identification/models/res_partner.py
  4. 26
      partner_identification/models/res_partner_id_category.py
  5. 6
      partner_identification/models/res_partner_id_number.py
  6. 14
      partner_identification/tests/test_partner_identification.py
  7. 5
      partner_identification/tests/test_res_partner.py
  8. 8
      partner_identification/views/res_partner_id_category_view.xml
  9. 6
      partner_identification/views/res_partner_id_number_view.xml
  10. 7
      partner_identification/views/res_partner_view.xml

27
partner_identification/README.rst

@ -27,7 +27,7 @@ No specific installation step required
Configuration Configuration
============= =============
Configure all ID types you need in Sales > Configuration > Contacts > Partner ID Categories.
Configure all ID types you need in Contacts > Configuration > Partner ID Categories.
For example, we create a category 'Driver License': For example, we create a category 'Driver License':
Name: Name:
@ -40,10 +40,10 @@ Python validation code:
.. code-block:: python .. code-block:: python
partner.with_context(id_no_validate=True).write({
'name': 'Bad Value',
'category_id': self.env.ref('id_category_only_numerics').id,
})
partner.with_context(id_no_validate=True).write({
'name': 'Bad Value',
'category_id': self.env.ref('id_category_only_numerics').id,
})
Usage Usage
===== =====
@ -70,7 +70,7 @@ Notes:
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/10.0
:target: https://runbot.odoo-community.org/runbot/134/11.0
Known issues / Roadmap Known issues / Roadmap
@ -86,16 +86,18 @@ Bug Tracker
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues
<https://github.com/OCA/partner_contact/issues>`_. In case of trouble, please <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, 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**>`_.
help us smash it by providing detailed and welcomed feedback.
Credits Credits
======= =======
Images
------
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
Contributors Contributors
------------ ------------
@ -105,6 +107,8 @@ Contributors
* Laurent Mignon <laurent.mignon@acsone.eu> * Laurent Mignon <laurent.mignon@acsone.eu>
* Jairo Llopis <jairo.llopis@tecnativa.com> * Jairo Llopis <jairo.llopis@tecnativa.com>
* Dave Lasley <dave@laslabs.com> * Dave Lasley <dave@laslabs.com>
* Simone Orsi <simone.orsi@camptocamp.com>
Maintainer Maintainer
---------- ----------
@ -120,4 +124,3 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
To contribute to this module, please visit https://odoo-community.org. To contribute to this module, please visit https://odoo-community.org.

15
partner_identification/__openerp__.py → partner_identification/__manifest__.py

@ -1,19 +1,20 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# © 2004-2010 Tiny SPRL http://tiny.be
# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# Copyright 2004-2010 Tiny SPRL http://tiny.be
# Copyright 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# http://www.camptocamp.at # http://www.camptocamp.at
# © 2015 Antiun Ingenieria, SL (Madrid, Spain)
# Copyright 2015 Antiun Ingenieria, SL (Madrid, Spain)
# http://www.antiun.com # http://www.antiun.com
# Antonio Espinosa <antonioea@antiun.com> # Antonio Espinosa <antonioea@antiun.com>
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Partner Identification Numbers', 'name': 'Partner Identification Numbers',
'category': 'Customer Relationship Management', 'category': 'Customer Relationship Management',
'version': '10.0.1.1.1',
'version': '11.0.1.0.0',
'license': 'AGPL-3',
'depends': [ 'depends': [
'sales_team',
'contacts',
], ],
'data': [ 'data': [
'views/res_partner_id_category_view.xml', 'views/res_partner_id_category_view.xml',
@ -28,6 +29,4 @@
'LasLabs,' 'LasLabs,'
'Odoo Community Association (OCA)', 'Odoo Community Association (OCA)',
'website': 'https://odoo-community.org/', 'website': 'https://odoo-community.org/',
'license': 'AGPL-3',
'installable': True,
} }

6
partner_identification/models/res_partner.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# © 2004-2010 Tiny SPRL http://tiny.be
# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# Copyright 2004-2010 Tiny SPRL http://tiny.be
# Copyright 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# http://www.camptocamp.at # http://www.camptocamp.at
# © 2015 Antiun Ingenieria, SL (Madrid, Spain)
# Copyright 2015 Antiun Ingenieria, SL (Madrid, Spain)
# http://www.antiun.com # http://www.antiun.com
# Antonio Espinosa <antonioea@antiun.com> # Antonio Espinosa <antonioea@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

26
partner_identification/models/res_partner_id_category.py

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# © 2004-2010 Tiny SPRL http://tiny.be
# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# Copyright 2004-2010 Tiny SPRL http://tiny.be
# Copyright 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# http://www.camptocamp.at # http://www.camptocamp.at
# © 2015 Antiun Ingenieria, SL (Madrid, Spain)
# Copyright 2015 Antiun Ingenieria, SL (Madrid, Spain)
# http://www.antiun.com # http://www.antiun.com
# Antonio Espinosa <antonioea@antiun.com> # Antonio Espinosa <antonioea@antiun.com>
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -19,14 +19,6 @@ class ResPartnerIdCategory(models.Model):
_name = "res.partner.id_category" _name = "res.partner.id_category"
_order = "name" _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( code = fields.Char(
string="Code", size=16, required=True, string="Code", size=16, required=True,
help="Abbreviation or acronym of this ID type. For example, " help="Abbreviation or acronym of this ID type. For example, "
@ -38,7 +30,15 @@ class ResPartnerIdCategory(models.Model):
validation_code = fields.Text( validation_code = fields.Text(
'Python validation code', 'Python validation code',
help="Python code called to validate an id number.", help="Python code called to validate an id number.",
default=_default_validation_code)
default=lambda self: self._default_validation_code())
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")
@api.multi @api.multi
def _validation_eval_context(self, id_number): def _validation_eval_context(self, id_number):

6
partner_identification/models/res_partner_id_number.py

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# © 2004-2010 Tiny SPRL http://tiny.be
# © 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# Copyright 2004-2010 Tiny SPRL http://tiny.be
# Copyright 2010-2012 ChriCar Beteiligungs- und Beratungs- GmbH
# http://www.camptocamp.at # http://www.camptocamp.at
# © 2015 Antiun Ingenieria, SL (Madrid, Spain)
# Copyright 2015 Antiun Ingenieria, SL (Madrid, Spain)
# http://www.antiun.com # http://www.antiun.com
# Antonio Espinosa <antonioea@antiun.com> # Antonio Espinosa <antonioea@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

14
partner_identification/tests/test_partner_identification.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from psycopg2._psycopg import IntegrityError from psycopg2._psycopg import IntegrityError
from odoo.tests import common from odoo.tests import common
@ -19,7 +19,7 @@ class TestPartnerIdentificationBase(common.TransactionCase):
self.assertEqual(partner_id_category.code, 'id_code') self.assertEqual(partner_id_category.code, 'id_code')
partner_1 = self.env.ref('base.res_partner_1') partner_1 = self.env.ref('base.res_partner_1')
self.assertEquals(len(partner_1.id_numbers), 0)
self.assertEqual(len(partner_1.id_numbers), 0)
# create without required category # create without required category
with self.assertRaises(IntegrityError), self.cr.savepoint(): with self.assertRaises(IntegrityError), self.cr.savepoint():
partner_1.write({'id_numbers': [(0, 0, { partner_1.write({'id_numbers': [(0, 0, {
@ -30,11 +30,11 @@ class TestPartnerIdentificationBase(common.TransactionCase):
'name': '1234', 'name': '1234',
'category_id': partner_id_category.id 'category_id': partner_id_category.id
})]}) })]})
self.assertEquals(len(partner_1.id_numbers), 1)
self.assertEquals(partner_1.id_numbers.name, '1234')
self.assertEqual(len(partner_1.id_numbers), 1)
self.assertEqual(partner_1.id_numbers.name, '1234')
# delete # delete
partner_1.write({'id_numbers': [(5, 0, 0)]}) partner_1.write({'id_numbers': [(5, 0, 0)]})
self.assertEquals(len(partner_1.id_numbers), 0)
self.assertEqual(len(partner_1.id_numbers), 0)
class TestPartnerCategoryValidation(common.TransactionCase): class TestPartnerCategoryValidation(common.TransactionCase):
@ -58,8 +58,8 @@ if id_number.name != '1234':
'name': '1234', 'name': '1234',
'category_id': partner_id_category.id 'category_id': partner_id_category.id
})]}) })]})
self.assertEquals(len(partner_1.id_numbers), 1)
self.assertEquals(partner_1.id_numbers.name, '1234')
self.assertEqual(len(partner_1.id_numbers), 1)
self.assertEqual(partner_1.id_numbers.name, '1234')
partner_id_category2 = self.env['res.partner.id_category'].create({ partner_id_category2 = self.env['res.partner.id_category'].create({
'code': 'id_code2', 'code': 'id_code2',

5
partner_identification/tests/test_res_partner.py

@ -40,12 +40,11 @@ class TestResPartner(common.SavepointCase):
inst = model_cls._build_model(registry, cr) inst = model_cls._build_model(registry, cr)
model = cls.env[model_cls._inherit].with_context(todo=[]) model = cls.env[model_cls._inherit].with_context(todo=[])
model._prepare_setup() model._prepare_setup()
model._setup_base(partial=False)
model._setup_fields(partial=False)
model._setup_base()
model._setup_fields()
model._setup_complete() model._setup_complete()
model._auto_init() model._auto_init()
model.init() model.init()
model._auto_end()
return inst return inst
@classmethod @classmethod

8
partner_identification/views/res_partner_id_category_view.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<odoo>
<!-- Partner Identification Number Categories --> <!-- Partner Identification Number Categories -->
<record id="view_partner_id_category_form" model="ir.ui.view"> <record id="view_partner_id_category_form" model="ir.ui.view">
@ -38,7 +37,6 @@
<menuitem action="action_partner_id_category" <menuitem action="action_partner_id_category"
id="menu_partner_id_category" id="menu_partner_id_category"
parent="sales_team.menu_config_address_book"/>
parent="contacts.res_partner_menu_config"/>
</data>
</openerp>
</odoo>

6
partner_identification/views/res_partner_id_number_view.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<odoo>
<record id="view_partner_id_numbers_form" model="ir.ui.view"> <record id="view_partner_id_numbers_form" model="ir.ui.view">
<field name="name">res.partner.id_number.form</field> <field name="name">res.partner.id_number.form</field>
@ -48,5 +47,4 @@
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </record>
</data>
</openerp>
</odoo>

7
partner_identification/views/res_partner_view.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<odoo>
<!-- Modification of Partner - Adding Tab for Idenification Numbers --> <!-- Modification of Partner - Adding Tab for Idenification Numbers -->
<record model="ir.ui.view" id="view_partner_form"> <record model="ir.ui.view" id="view_partner_form">
@ -18,6 +17,4 @@
</field> </field>
</record> </record>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save