From e3483be0f062f942be6d0b7c30a4a6cb728dc60c Mon Sep 17 00:00:00 2001 From: gilles Date: Thu, 6 Jul 2017 18:07:43 +0200 Subject: [PATCH] [MIG] Partner Identification Gln v10 --- partner_identification_gln/README.rst | 5 +-- partner_identification_gln/__init__.py | 3 ++ .../{__openerp__.py => __manifest__.py} | 6 +-- .../data/partner_identification_gln.xml | 28 ++++++------ partner_identification_gln/models/__init__.py | 4 +- partner_identification_gln/models/partner.py | 7 ++- partner_identification_gln/tests/__init__.py | 4 +- partner_identification_gln/tests/test_gln.py | 43 ++++++++++++------- 8 files changed, 57 insertions(+), 43 deletions(-) rename partner_identification_gln/{__openerp__.py => __manifest__.py} (78%) diff --git a/partner_identification_gln/README.rst b/partner_identification_gln/README.rst index e59a31c8e..de1d7da25 100644 --- a/partner_identification_gln/README.rst +++ b/partner_identification_gln/README.rst @@ -20,10 +20,6 @@ This module depends on 'stdnum' python module :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/repo/github-com-oca-partner-contact-134 -.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt -.. branch is "8.0" for example - - Bug Tracker =========== @@ -44,6 +40,7 @@ Contributors ------------ * Denis Roussel +* Meyomesse Gilles Maintainer ---------- diff --git a/partner_identification_gln/__init__.py b/partner_identification_gln/__init__.py index a9e337226..9e7304ea3 100644 --- a/partner_identification_gln/__init__.py +++ b/partner_identification_gln/__init__.py @@ -1,2 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/partner_identification_gln/__openerp__.py b/partner_identification_gln/__manifest__.py similarity index 78% rename from partner_identification_gln/__openerp__.py rename to partner_identification_gln/__manifest__.py index 305ef2bb8..ced0818dc 100644 --- a/partner_identification_gln/__openerp__.py +++ b/partner_identification_gln/__manifest__.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Acsone S.A. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# Copyright 2016-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Partner Identification Gln', 'summary': """ This addon extends "Partner Identification Numbers" to provide a number category for GLN registration""", - 'version': '8.0.1.0.0', + 'version': '10.0.1.0.0', 'license': 'AGPL-3', 'author': 'Acsone S.A.,Odoo Community Association (OCA)', 'website': 'https://www.acsone.eu', diff --git a/partner_identification_gln/data/partner_identification_gln.xml b/partner_identification_gln/data/partner_identification_gln.xml index a0649dd1b..e047a1ce7 100644 --- a/partner_identification_gln/data/partner_identification_gln.xml +++ b/partner_identification_gln/data/partner_identification_gln.xml @@ -1,15 +1,15 @@ - - - - GLN Identification Number - gln_id_number - - - - GCP Identification Number - gcp_id_number - - - - \ No newline at end of file + + + + GLN Identification Number + gln_id_number + + + + GCP Identification Number + gcp_id_number + + + \ No newline at end of file diff --git a/partner_identification_gln/models/__init__.py b/partner_identification_gln/models/__init__.py index 4f649425e..de83392e6 100644 --- a/partner_identification_gln/models/__init__.py +++ b/partner_identification_gln/models/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Acsone S.A. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# Copyright 2016-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import partner diff --git a/partner_identification_gln/models/partner.py b/partner_identification_gln/models/partner.py index f04a835d9..9ea5f45e2 100644 --- a/partner_identification_gln/models/partner.py +++ b/partner_identification_gln/models/partner.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- -# © 2016 ACSONE SA/NV () +# Copyright 2016-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + import logging -from openerp import api, models + +from odoo import api, models + _logger = logging.getLogger(__name__) try: diff --git a/partner_identification_gln/tests/__init__.py b/partner_identification_gln/tests/__init__.py index a064df9b0..56bc9598b 100644 --- a/partner_identification_gln/tests/__init__.py +++ b/partner_identification_gln/tests/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Acsone S.A. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# Copyright 2016-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import test_gln diff --git a/partner_identification_gln/tests/test_gln.py b/partner_identification_gln/tests/test_gln.py index 50f7459e3..9560ba6df 100644 --- a/partner_identification_gln/tests/test_gln.py +++ b/partner_identification_gln/tests/test_gln.py @@ -2,35 +2,37 @@ # Copyright 2016 Acsone S.A. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.exceptions import ValidationError -from openerp.tests.common import TransactionCase +from odoo.exceptions import ValidationError +from odoo.tests.common import SavepointCase -class TestGLN(TransactionCase): - def setUp(self): - super(TestGLN, self).setUp() - self.partner = self.env['res.partner'].create({'name': 'TestGLN'}) - self.partner2 = self.env['res.partner'].create({'name': 'TestGLN2'}) - pc = self.env.ref('partner_identification_gln.' - 'partner_identification_gln_number_category') - self.partner_id_category = pc +class TestGLN(SavepointCase): - pc_gcp = self.env.ref('partner_identification_gln.' - 'partner_identification_gcp_number_category') - self.partner_id_gcp_category = pc_gcp + def setUp(cls): + super(TestGLN, cls).setUp() + cls.partner = cls.env['res.partner'].create({'name': 'TestGLN'}) + cls.partner2 = cls.env['res.partner'].create({'name': 'TestGLN2'}) + pc = cls.env.ref('partner_identification_gln.' + 'partner_identification_gln_number_category') + cls.partner_id_category = pc + + pc_gcp = cls.env.ref('partner_identification_gln.' + 'partner_identification_gcp_number_category') + cls.partner_id_gcp_category = pc_gcp def test_gln(self): # Good GLN - vals = {'name': '5450534001717', + vals = {'name': '5450534005852', 'category_id': self.partner_id_category.id } + self.partner.write({'id_numbers': [(0, 0, vals)]}) id_number = self.partner.id_numbers[0] - self.assertEqual(id_number.name, '5450534001717') + self.assertEqual(id_number.name, '5450534005852') # Duplicate GLN - vals = {'name': '5450534001717', + vals = {'name': '5450534005852', 'category_id': self.partner_id_category.id } @@ -44,6 +46,10 @@ class TestGLN(TransactionCase): with self.assertRaises(ValidationError): self.partner.write({'id_numbers': [(0, 0, vals)]}) + def test_gln_with_no_number(self): + self.assertFalse( + self.partner_id_category.validate_res_partner_gln(id_number=None)) + def test_gcp(self): # Good GLN vals = {'name': '545053', @@ -68,3 +74,8 @@ class TestGLN(TransactionCase): } with self.assertRaises(ValidationError): self.partner.write({'id_numbers': [(0, 0, vals)]}) + + def test_gcp_with_no_number(self): + self.assertFalse( + self.partner_id_gcp_category.validate_res_partner_gln( + id_number=None))