From 707a05fa90ff49703381fda0f33e6ce83e7d87fb Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Wed, 29 Nov 2017 15:13:08 +0100 Subject: [PATCH] [11.0][MIG] partner_identification --- partner_identification/README.rst | 27 ++++++++++--------- .../{__openerp__.py => __manifest__.py} | 15 +++++------ partner_identification/models/res_partner.py | 6 ++--- .../models/res_partner_id_category.py | 26 +++++++++--------- .../models/res_partner_id_number.py | 6 ++--- .../tests/test_partner_identification.py | 14 +++++----- .../tests/test_res_partner.py | 5 ++-- .../views/res_partner_id_category_view.xml | 8 +++--- .../views/res_partner_id_number_view.xml | 6 ++--- .../views/res_partner_view.xml | 7 ++--- 10 files changed, 57 insertions(+), 63 deletions(-) rename partner_identification/{__openerp__.py => __manifest__.py} (75%) diff --git a/partner_identification/README.rst b/partner_identification/README.rst index 1c5689789..b2476c9c2 100644 --- a/partner_identification/README.rst +++ b/partner_identification/README.rst @@ -27,7 +27,7 @@ No specific installation step required 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': Name: @@ -40,10 +40,10 @@ Python validation code: .. 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 ===== @@ -70,7 +70,7 @@ Notes: .. 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/10.0 + :target: https://runbot.odoo-community.org/runbot/134/11.0 Known issues / Roadmap @@ -86,16 +86,18 @@ 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 -`_. +help us smash it by providing detailed and welcomed feedback. Credits ======= +Images +------ + +* Odoo Community Association: `Icon `_. + + Contributors ------------ @@ -105,6 +107,8 @@ Contributors * Laurent Mignon * Jairo Llopis * Dave Lasley +* Simone Orsi + Maintainer ---------- @@ -120,4 +124,3 @@ 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/__openerp__.py b/partner_identification/__manifest__.py similarity index 75% rename from partner_identification/__openerp__.py rename to partner_identification/__manifest__.py index e54d2c0aa..e10cabebb 100644 --- a/partner_identification/__openerp__.py +++ b/partner_identification/__manifest__.py @@ -1,19 +1,20 @@ # -*- 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 -# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# Copyright 2015 Antiun Ingenieria, SL (Madrid, Spain) # http://www.antiun.com # Antonio Espinosa -# © 2016 ACSONE SA/NV () +# Copyright 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': '10.0.1.1.1', + 'version': '11.0.1.0.0', + 'license': 'AGPL-3', 'depends': [ - 'sales_team', + 'contacts', ], 'data': [ 'views/res_partner_id_category_view.xml', @@ -28,6 +29,4 @@ 'LasLabs,' 'Odoo Community Association (OCA)', 'website': 'https://odoo-community.org/', - 'license': 'AGPL-3', - 'installable': True, } diff --git a/partner_identification/models/res_partner.py b/partner_identification/models/res_partner.py index 0c56f3b7a..522d46206 100644 --- a/partner_identification/models/res_partner.py +++ b/partner_identification/models/res_partner.py @@ -1,9 +1,9 @@ # -*- 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 -# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# Copyright 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). diff --git a/partner_identification/models/res_partner_id_category.py b/partner_identification/models/res_partner_id_category.py index 09a8e660d..b9cfca7ad 100644 --- a/partner_identification/models/res_partner_id_category.py +++ b/partner_identification/models/res_partner_id_category.py @@ -1,12 +1,12 @@ # -*- 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 -# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# Copyright 2015 Antiun Ingenieria, SL (Madrid, Spain) # http://www.antiun.com # Antonio Espinosa -# © 2016 ACSONE SA/NV () +# Copyright 2016 ACSONE SA/NV () # 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" _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, " @@ -38,7 +30,15 @@ class ResPartnerIdCategory(models.Model): validation_code = fields.Text( 'Python validation code', 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 def _validation_eval_context(self, id_number): diff --git a/partner_identification/models/res_partner_id_number.py b/partner_identification/models/res_partner_id_number.py index 8138116ec..ddb146b1f 100644 --- a/partner_identification/models/res_partner_id_number.py +++ b/partner_identification/models/res_partner_id_number.py @@ -1,9 +1,9 @@ # -*- 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 -# © 2015 Antiun Ingenieria, SL (Madrid, Spain) +# Copyright 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). diff --git a/partner_identification/tests/test_partner_identification.py b/partner_identification/tests/test_partner_identification.py index eb3945dec..9804eb5a7 100644 --- a/partner_identification/tests/test_partner_identification.py +++ b/partner_identification/tests/test_partner_identification.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 ACSONE SA/NV () +# Copyright 2016 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from psycopg2._psycopg import IntegrityError from odoo.tests import common @@ -19,7 +19,7 @@ class TestPartnerIdentificationBase(common.TransactionCase): 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) + self.assertEqual(len(partner_1.id_numbers), 0) # create without required category with self.assertRaises(IntegrityError), self.cr.savepoint(): partner_1.write({'id_numbers': [(0, 0, { @@ -30,11 +30,11 @@ class TestPartnerIdentificationBase(common.TransactionCase): 'name': '1234', '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 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): @@ -58,8 +58,8 @@ if id_number.name != '1234': 'name': '1234', '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({ 'code': 'id_code2', diff --git a/partner_identification/tests/test_res_partner.py b/partner_identification/tests/test_res_partner.py index c06670b8d..e0f295442 100644 --- a/partner_identification/tests/test_res_partner.py +++ b/partner_identification/tests/test_res_partner.py @@ -40,12 +40,11 @@ class TestResPartner(common.SavepointCase): inst = model_cls._build_model(registry, cr) model = cls.env[model_cls._inherit].with_context(todo=[]) model._prepare_setup() - model._setup_base(partial=False) - model._setup_fields(partial=False) + model._setup_base() + model._setup_fields() model._setup_complete() model._auto_init() model.init() - model._auto_end() return inst @classmethod diff --git a/partner_identification/views/res_partner_id_category_view.xml b/partner_identification/views/res_partner_id_category_view.xml index 7b7bad04a..885b0ae23 100644 --- a/partner_identification/views/res_partner_id_category_view.xml +++ b/partner_identification/views/res_partner_id_category_view.xml @@ -1,6 +1,5 @@ - - + @@ -38,7 +37,6 @@ + parent="contacts.res_partner_menu_config"/> - - + diff --git a/partner_identification/views/res_partner_id_number_view.xml b/partner_identification/views/res_partner_id_number_view.xml index 00f325ff8..0f07f79f8 100644 --- a/partner_identification/views/res_partner_id_number_view.xml +++ b/partner_identification/views/res_partner_id_number_view.xml @@ -1,6 +1,5 @@ - - + res.partner.id_number.form @@ -48,5 +47,4 @@ tree,form - - + diff --git a/partner_identification/views/res_partner_view.xml b/partner_identification/views/res_partner_view.xml index eddea27a9..0ba035332 100644 --- a/partner_identification/views/res_partner_view.xml +++ b/partner_identification/views/res_partner_view.xml @@ -1,6 +1,5 @@ - - + @@ -18,6 +17,4 @@ - - - +