From c4a7116964080e404dfd7839f6641f937b589550 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Mon, 8 Aug 2016 09:58:31 +0200 Subject: [PATCH 1/7] Add module to manage GLN partner identification number --- partner_identification_gln/README.rst | 61 ++++++++++++++ partner_identification_gln/__init__.py | 2 + partner_identification_gln/__openerp__.py | 23 ++++++ .../data/partner_identification_gln.xml | 15 ++++ partner_identification_gln/models/__init__.py | 5 ++ partner_identification_gln/models/partner.py | 65 +++++++++++++++ .../static/description/icon.svg | 79 +++++++++++++++++++ partner_identification_gln/tests/__init__.py | 5 ++ partner_identification_gln/tests/test_gln.py | 70 ++++++++++++++++ 9 files changed, 325 insertions(+) create mode 100644 partner_identification_gln/README.rst create mode 100644 partner_identification_gln/__init__.py create mode 100644 partner_identification_gln/__openerp__.py create mode 100644 partner_identification_gln/data/partner_identification_gln.xml create mode 100644 partner_identification_gln/models/__init__.py create mode 100644 partner_identification_gln/models/partner.py create mode 100644 partner_identification_gln/static/description/icon.svg create mode 100644 partner_identification_gln/tests/__init__.py create mode 100644 partner_identification_gln/tests/test_gln.py diff --git a/partner_identification_gln/README.rst b/partner_identification_gln/README.rst new file mode 100644 index 000000000..e59a31c8e --- /dev/null +++ b/partner_identification_gln/README.rst @@ -0,0 +1,61 @@ +.. 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 Gln +========================== + +This addon extends "Partner Identification Numbers" to provide a number category for GLN registration + +see: http://www.gs1.org/1/glnrules/en/ + +Installation +============ + +This module depends on 'stdnum' python module + + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :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 +=========== + +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 +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Denis Roussel + +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_gln/__init__.py b/partner_identification_gln/__init__.py new file mode 100644 index 000000000..a9e337226 --- /dev/null +++ b/partner_identification_gln/__init__.py @@ -0,0 +1,2 @@ + +from . import models diff --git a/partner_identification_gln/__openerp__.py b/partner_identification_gln/__openerp__.py new file mode 100644 index 000000000..305ef2bb8 --- /dev/null +++ b/partner_identification_gln/__openerp__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Acsone S.A. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + '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', + 'license': 'AGPL-3', + 'author': 'Acsone S.A.,Odoo Community Association (OCA)', + 'website': 'https://www.acsone.eu', + 'external_dependencies': { + 'python': ['stdnum' + ], + }, + 'depends': ['partner_identification' + ], + 'data': ['data/partner_identification_gln.xml' + ], + 'installable': True, +} diff --git a/partner_identification_gln/data/partner_identification_gln.xml b/partner_identification_gln/data/partner_identification_gln.xml new file mode 100644 index 000000000..a0649dd1b --- /dev/null +++ b/partner_identification_gln/data/partner_identification_gln.xml @@ -0,0 +1,15 @@ + + + + + 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 new file mode 100644 index 000000000..4f649425e --- /dev/null +++ b/partner_identification_gln/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Acsone S.A. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import partner diff --git a/partner_identification_gln/models/partner.py b/partner_identification_gln/models/partner.py new file mode 100644 index 000000000..f04a835d9 --- /dev/null +++ b/partner_identification_gln/models/partner.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import logging +from openerp import api, models +_logger = logging.getLogger(__name__) + +try: + from stdnum import ean + from stdnum.exceptions import InvalidChecksum +except ImportError: + _logger.debug('Cannot `import external dependency python stdnum package`.') + + +class ResPartnerIdCategory(models.Model): + _inherit = 'res.partner.id_category' + + def _search_duplicate(self, category_id, id_number, force_active=False): + domain = [('category_id', '=', category_id), + ('name', '=', id_number.name), + ('name', '!=', False), + ('id', '!=', id_number.id)] + + if force_active: + domain.append(('partner_id.active', '=', True)) + num_obj = self.env['res.partner.id_number'] + return num_obj.search(domain) + + @api.multi + def validate_res_partner_gln(self, id_number): + self.ensure_one() + if not id_number: + return False + + try: + ean.validate(id_number.name) + except InvalidChecksum: + return True + + cat = self.env.ref('partner_identification_gln.' + 'partner_identification_gln_number_category').id + duplicate_gln = self._search_duplicate(cat, id_number, True) + + if duplicate_gln: + return True + + return False + + @api.multi + def validate_res_partner_gcp(self, id_number): + self.ensure_one() + if not id_number: + return False + + if len(id_number.name) < 1 or len(id_number.name) > 12: + return True + + cat = self.env.ref('partner_identification_gln.' + 'partner_identification_gcp_number_category').id + duplicate_gln = self._search_duplicate(cat, id_number) + + if duplicate_gln: + return True + + return False diff --git a/partner_identification_gln/static/description/icon.svg b/partner_identification_gln/static/description/icon.svg new file mode 100644 index 000000000..a7a26d093 --- /dev/null +++ b/partner_identification_gln/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/partner_identification_gln/tests/__init__.py b/partner_identification_gln/tests/__init__.py new file mode 100644 index 000000000..a064df9b0 --- /dev/null +++ b/partner_identification_gln/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Acsone S.A. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_gln diff --git a/partner_identification_gln/tests/test_gln.py b/partner_identification_gln/tests/test_gln.py new file mode 100644 index 000000000..50f7459e3 --- /dev/null +++ b/partner_identification_gln/tests/test_gln.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# 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 + + +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 + + pc_gcp = self.env.ref('partner_identification_gln.' + 'partner_identification_gcp_number_category') + self.partner_id_gcp_category = pc_gcp + + def test_gln(self): + # Good GLN + vals = {'name': '5450534001717', + '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') + + # Duplicate GLN + vals = {'name': '5450534001717', + 'category_id': self.partner_id_category.id + } + + with self.assertRaises(ValidationError): + self.partner2.write({'id_numbers': [(0, 0, vals)]}) + + # Bad GLN + vals = {'name': '5450534001716', + 'category_id': self.partner_id_category.id + } + with self.assertRaises(ValidationError): + self.partner.write({'id_numbers': [(0, 0, vals)]}) + + def test_gcp(self): + # Good GLN + vals = {'name': '545053', + 'category_id': self.partner_id_gcp_category.id + } + self.partner.write({'id_numbers': [(0, 0, vals)]}) + id_number = self.partner.id_numbers[0] + + self.assertEqual(id_number.name, '545053') + + # Duplicate GLN + vals = {'name': '545053', + 'category_id': self.partner_id_gcp_category.id + } + + with self.assertRaises(ValidationError): + self.partner2.write({'id_numbers': [(0, 0, vals)]}) + + # Bad GLN + vals = {'name': '5450534001716', + 'category_id': self.partner_id_gcp_category.id + } + with self.assertRaises(ValidationError): + self.partner.write({'id_numbers': [(0, 0, vals)]}) From 7ae4ff592c3372c9d26b4b239c1616ebf8337b0c Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 3 Jun 2017 06:35:35 +0200 Subject: [PATCH 2/7] OCA Transbot updated translations from Transifex --- partner_identification_gln/i18n/sl.po | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 partner_identification_gln/i18n/sl.po diff --git a/partner_identification_gln/i18n/sl.po b/partner_identification_gln/i18n/sl.po new file mode 100644 index 000000000..7d951d030 --- /dev/null +++ b/partner_identification_gln/i18n/sl.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_gln +# +# Translators: +# Matjaž Mozetič , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-01 03:23+0000\n" +"PO-Revision-Date: 2017-06-01 03:23+0000\n" +"Last-Translator: Matjaž Mozetič , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gcp_number_category +msgid "GCP Identification Number" +msgstr "GCP identifikacijska številka" + +#. module: partner_identification_gln +#: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gln_number_category +msgid "GLN Identification Number" +msgstr "GLN identifikacijska številka" From b4a104b8e436adcb46559d76c29063052f798ed0 Mon Sep 17 00:00:00 2001 From: gilles Date: Thu, 6 Jul 2017 18:07:43 +0200 Subject: [PATCH 3/7] [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)) From 27f326d419d4ac31ecb36a223942dad2e2a6c828 Mon Sep 17 00:00:00 2001 From: BT-aestebanez Date: Wed, 11 Sep 2019 14:55:53 +0200 Subject: [PATCH 4/7] [MIG] partner_identification_gln: Migration to 12.0 --- partner_identification_gln/README.rst | 1 + partner_identification_gln/__init__.py | 3 --- partner_identification_gln/__manifest__.py | 20 ++++++++++--------- .../data/partner_identification_gln.xml | 6 +++--- partner_identification_gln/i18n/sl.po | 18 +++++++++-------- partner_identification_gln/models/__init__.py | 5 +---- ...{partner.py => res_partner_id_category.py} | 5 ++--- partner_identification_gln/tests/__init__.py | 3 --- partner_identification_gln/tests/test_gln.py | 1 - 9 files changed, 28 insertions(+), 34 deletions(-) rename partner_identification_gln/models/{partner.py => res_partner_id_category.py} (94%) diff --git a/partner_identification_gln/README.rst b/partner_identification_gln/README.rst index de1d7da25..dbeb69323 100644 --- a/partner_identification_gln/README.rst +++ b/partner_identification_gln/README.rst @@ -39,6 +39,7 @@ Images Contributors ------------ +* Alvaro Estebanez * Denis Roussel * Meyomesse Gilles diff --git a/partner_identification_gln/__init__.py b/partner_identification_gln/__init__.py index 9e7304ea3..a9e337226 100644 --- a/partner_identification_gln/__init__.py +++ b/partner_identification_gln/__init__.py @@ -1,5 +1,2 @@ -# -*- 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/__manifest__.py b/partner_identification_gln/__manifest__.py index ced0818dc..62482104e 100644 --- a/partner_identification_gln/__manifest__.py +++ b/partner_identification_gln/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -7,17 +6,20 @@ 'summary': """ This addon extends "Partner Identification Numbers" to provide a number category for GLN registration""", - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'license': 'AGPL-3', 'author': 'Acsone S.A.,Odoo Community Association (OCA)', - 'website': 'https://www.acsone.eu', + 'website': 'https://github.com/OCA/partner-contact', 'external_dependencies': { - 'python': ['stdnum' - ], + 'python': [ + 'stdnum', + ], }, - 'depends': ['partner_identification' - ], - 'data': ['data/partner_identification_gln.xml' - ], + 'depends': [ + 'partner_identification', + ], + 'data': [ + 'data/partner_identification_gln.xml', + ], 'installable': True, } diff --git a/partner_identification_gln/data/partner_identification_gln.xml b/partner_identification_gln/data/partner_identification_gln.xml index e047a1ce7..132d539d4 100644 --- a/partner_identification_gln/data/partner_identification_gln.xml +++ b/partner_identification_gln/data/partner_identification_gln.xml @@ -2,14 +2,14 @@ - + GLN Identification Number gln_id_number - + GCP Identification Number gcp_id_number - \ No newline at end of file + diff --git a/partner_identification_gln/i18n/sl.po b/partner_identification_gln/i18n/sl.po index 7d951d030..b54d605c5 100644 --- a/partner_identification_gln/i18n/sl.po +++ b/partner_identification_gln/i18n/sl.po @@ -1,21 +1,18 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * partner_identification_gln -# -# Translators: -# Matjaž Mozetič , 2017 +# * partner_identification_gln +# msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-06-01 03:23+0000\n" -"PO-Revision-Date: 2017-06-01 03:23+0000\n" +"POT-Creation-Date: 2019-09-11 11:05+0000\n" +"PO-Revision-Date: 2019-09-11 11:05+0000\n" "Last-Translator: Matjaž Mozetič , 2017\n" "Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: sl\n" "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" #. module: partner_identification_gln @@ -27,3 +24,8 @@ msgstr "GCP identifikacijska številka" #: model:res.partner.id_category,name:partner_identification_gln.partner_identification_gln_number_category msgid "GLN Identification Number" msgstr "GLN identifikacijska številka" + +#. module: partner_identification_gln +#: model:ir.model,name:partner_identification_gln.model_res_partner_id_category +msgid "Partner ID Category" +msgstr "Partnerjeve ID kategorije" diff --git a/partner_identification_gln/models/__init__.py b/partner_identification_gln/models/__init__.py index de83392e6..045a6d0d9 100644 --- a/partner_identification_gln/models/__init__.py +++ b/partner_identification_gln/models/__init__.py @@ -1,5 +1,2 @@ -# -*- coding: utf-8 -*- -# Copyright 2016-2017 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import partner +from . import res_partner_id_category diff --git a/partner_identification_gln/models/partner.py b/partner_identification_gln/models/res_partner_id_category.py similarity index 94% rename from partner_identification_gln/models/partner.py rename to partner_identification_gln/models/res_partner_id_category.py index 9ea5f45e2..63a7d4151 100644 --- a/partner_identification_gln/models/partner.py +++ b/partner_identification_gln/models/res_partner_id_category.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -18,6 +17,7 @@ except ImportError: class ResPartnerIdCategory(models.Model): _inherit = 'res.partner.id_category' + @api.model def _search_duplicate(self, category_id, id_number, force_active=False): domain = [('category_id', '=', category_id), ('name', '=', id_number.name), @@ -26,8 +26,7 @@ class ResPartnerIdCategory(models.Model): if force_active: domain.append(('partner_id.active', '=', True)) - num_obj = self.env['res.partner.id_number'] - return num_obj.search(domain) + return self.env['res.partner.id_number'].search(domain) @api.multi def validate_res_partner_gln(self, id_number): diff --git a/partner_identification_gln/tests/__init__.py b/partner_identification_gln/tests/__init__.py index 56bc9598b..a7f8eb649 100644 --- a/partner_identification_gln/tests/__init__.py +++ b/partner_identification_gln/tests/__init__.py @@ -1,5 +1,2 @@ -# -*- coding: utf-8 -*- -# 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 9560ba6df..94b631afe 100644 --- a/partner_identification_gln/tests/test_gln.py +++ b/partner_identification_gln/tests/test_gln.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Acsone S.A. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). From 5e8a457688a4bbada803f9b1a212f9a8c53cffe2 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 22 Jun 2020 14:04:47 +0200 Subject: [PATCH 5/7] [13.0][MIG] - migration partner_identification_gln --- partner_identification_gln/__init__.py | 1 - partner_identification_gln/__manifest__.py | 28 +++----- .../data/partner_identification_gln.xml | 20 ++++-- partner_identification_gln/models/__init__.py | 1 - .../models/res_partner_id_category.py | 30 ++++---- .../readme/CONTRIBUTORS.rst | 4 ++ .../readme/DESCRIPTION.rst | 3 + partner_identification_gln/readme/INSTALL.rst | 1 + partner_identification_gln/tests/__init__.py | 1 - partner_identification_gln/tests/test_gln.py | 72 ++++++++----------- 10 files changed, 80 insertions(+), 81 deletions(-) create mode 100644 partner_identification_gln/readme/CONTRIBUTORS.rst create mode 100644 partner_identification_gln/readme/DESCRIPTION.rst create mode 100644 partner_identification_gln/readme/INSTALL.rst diff --git a/partner_identification_gln/__init__.py b/partner_identification_gln/__init__.py index a9e337226..0650744f6 100644 --- a/partner_identification_gln/__init__.py +++ b/partner_identification_gln/__init__.py @@ -1,2 +1 @@ - from . import models diff --git a/partner_identification_gln/__manifest__.py b/partner_identification_gln/__manifest__.py index 62482104e..4aa0917a8 100644 --- a/partner_identification_gln/__manifest__.py +++ b/partner_identification_gln/__manifest__.py @@ -2,24 +2,16 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': 'Partner Identification Gln', - 'summary': """ + "name": "Partner Identification Gln", + "summary": """ This addon extends "Partner Identification Numbers" to provide a number category for GLN registration""", - 'version': '12.0.1.0.0', - 'license': 'AGPL-3', - 'author': 'Acsone S.A.,Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/partner-contact', - 'external_dependencies': { - 'python': [ - 'stdnum', - ], - }, - 'depends': [ - 'partner_identification', - ], - 'data': [ - 'data/partner_identification_gln.xml', - ], - 'installable': True, + "version": "13.0.1.0.0", + "license": "AGPL-3", + "author": "Acsone S.A.,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/partner-contact", + "external_dependencies": {"python": ["stdnum"]}, + "depends": ["partner_identification"], + "data": ["data/partner_identification_gln.xml"], + "installable": True, } diff --git a/partner_identification_gln/data/partner_identification_gln.xml b/partner_identification_gln/data/partner_identification_gln.xml index 132d539d4..d917e776a 100644 --- a/partner_identification_gln/data/partner_identification_gln.xml +++ b/partner_identification_gln/data/partner_identification_gln.xml @@ -1,15 +1,25 @@ - + - + GLN Identification Number gln_id_number - + - + GCP Identification Number gcp_id_number - + diff --git a/partner_identification_gln/models/__init__.py b/partner_identification_gln/models/__init__.py index 045a6d0d9..3ca19e1ae 100644 --- a/partner_identification_gln/models/__init__.py +++ b/partner_identification_gln/models/__init__.py @@ -1,2 +1 @@ - from . import res_partner_id_category diff --git a/partner_identification_gln/models/res_partner_id_category.py b/partner_identification_gln/models/res_partner_id_category.py index 63a7d4151..ff42d5922 100644 --- a/partner_identification_gln/models/res_partner_id_category.py +++ b/partner_identification_gln/models/res_partner_id_category.py @@ -11,24 +11,25 @@ try: from stdnum import ean from stdnum.exceptions import InvalidChecksum except ImportError: - _logger.debug('Cannot `import external dependency python stdnum package`.') + _logger.debug("Cannot `import external dependency python stdnum package`.") class ResPartnerIdCategory(models.Model): - _inherit = 'res.partner.id_category' + _inherit = "res.partner.id_category" @api.model def _search_duplicate(self, category_id, id_number, force_active=False): - domain = [('category_id', '=', category_id), - ('name', '=', id_number.name), - ('name', '!=', False), - ('id', '!=', id_number.id)] + domain = [ + ("category_id", "=", category_id), + ("name", "=", id_number.name), + ("name", "!=", False), + ("id", "!=", id_number.id), + ] if force_active: - domain.append(('partner_id.active', '=', True)) - return self.env['res.partner.id_number'].search(domain) + domain.append(("partner_id.active", "=", True)) + return self.env["res.partner.id_number"].search(domain) - @api.multi def validate_res_partner_gln(self, id_number): self.ensure_one() if not id_number: @@ -39,8 +40,9 @@ class ResPartnerIdCategory(models.Model): except InvalidChecksum: return True - cat = self.env.ref('partner_identification_gln.' - 'partner_identification_gln_number_category').id + cat = self.env.ref( + "partner_identification_gln." "partner_identification_gln_number_category" + ).id duplicate_gln = self._search_duplicate(cat, id_number, True) if duplicate_gln: @@ -48,7 +50,6 @@ class ResPartnerIdCategory(models.Model): return False - @api.multi def validate_res_partner_gcp(self, id_number): self.ensure_one() if not id_number: @@ -57,8 +58,9 @@ class ResPartnerIdCategory(models.Model): if len(id_number.name) < 1 or len(id_number.name) > 12: return True - cat = self.env.ref('partner_identification_gln.' - 'partner_identification_gcp_number_category').id + cat = self.env.ref( + "partner_identification_gln." "partner_identification_gcp_number_category" + ).id duplicate_gln = self._search_duplicate(cat, id_number) if duplicate_gln: diff --git a/partner_identification_gln/readme/CONTRIBUTORS.rst b/partner_identification_gln/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..42b018f96 --- /dev/null +++ b/partner_identification_gln/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Alvaro Estebanez +* Denis Roussel +* Meyomesse Gilles +* Bejaoui Souheil diff --git a/partner_identification_gln/readme/DESCRIPTION.rst b/partner_identification_gln/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b8bcc979e --- /dev/null +++ b/partner_identification_gln/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This addon extends "Partner Identification Numbers" to provide a number category for GLN registration + +see: http://www.gs1.org/1/glnrules/en/ diff --git a/partner_identification_gln/readme/INSTALL.rst b/partner_identification_gln/readme/INSTALL.rst new file mode 100644 index 000000000..ecf4e9c16 --- /dev/null +++ b/partner_identification_gln/readme/INSTALL.rst @@ -0,0 +1 @@ +This module depends on 'stdnum' python module diff --git a/partner_identification_gln/tests/__init__.py b/partner_identification_gln/tests/__init__.py index a7f8eb649..bd636d043 100644 --- a/partner_identification_gln/tests/__init__.py +++ b/partner_identification_gln/tests/__init__.py @@ -1,2 +1 @@ - from . import test_gln diff --git a/partner_identification_gln/tests/test_gln.py b/partner_identification_gln/tests/test_gln.py index 94b631afe..6d3e5b7a7 100644 --- a/partner_identification_gln/tests/test_gln.py +++ b/partner_identification_gln/tests/test_gln.py @@ -6,75 +6,65 @@ from odoo.tests.common import SavepointCase class TestGLN(SavepointCase): - - 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 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 + + pc_gcp = self.env.ref( + "partner_identification_gln." "partner_identification_gcp_number_category" + ) + self.partner_id_gcp_category = pc_gcp def test_gln(self): # Good GLN - vals = {'name': '5450534005852', - 'category_id': self.partner_id_category.id - } + vals = {"name": "5450534005852", "category_id": self.partner_id_category.id} - self.partner.write({'id_numbers': [(0, 0, vals)]}) + self.partner.write({"id_numbers": [(0, 0, vals)]}) id_number = self.partner.id_numbers[0] - self.assertEqual(id_number.name, '5450534005852') + self.assertEqual(id_number.name, "5450534005852") # Duplicate GLN - vals = {'name': '5450534005852', - 'category_id': self.partner_id_category.id - } + vals = {"name": "5450534005852", "category_id": self.partner_id_category.id} with self.assertRaises(ValidationError): - self.partner2.write({'id_numbers': [(0, 0, vals)]}) + self.partner2.write({"id_numbers": [(0, 0, vals)]}) # Bad GLN - vals = {'name': '5450534001716', - 'category_id': self.partner_id_category.id - } + vals = {"name": "5450534001716", "category_id": self.partner_id_category.id} with self.assertRaises(ValidationError): - self.partner.write({'id_numbers': [(0, 0, vals)]}) + 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)) + self.partner_id_category.validate_res_partner_gln(id_number=None) + ) def test_gcp(self): # Good GLN - vals = {'name': '545053', - 'category_id': self.partner_id_gcp_category.id - } - self.partner.write({'id_numbers': [(0, 0, vals)]}) + vals = {"name": "545053", "category_id": self.partner_id_gcp_category.id} + self.partner.write({"id_numbers": [(0, 0, vals)]}) id_number = self.partner.id_numbers[0] - self.assertEqual(id_number.name, '545053') + self.assertEqual(id_number.name, "545053") # Duplicate GLN - vals = {'name': '545053', - 'category_id': self.partner_id_gcp_category.id - } + vals = {"name": "545053", "category_id": self.partner_id_gcp_category.id} with self.assertRaises(ValidationError): - self.partner2.write({'id_numbers': [(0, 0, vals)]}) + self.partner2.write({"id_numbers": [(0, 0, vals)]}) # Bad GLN - vals = {'name': '5450534001716', - 'category_id': self.partner_id_gcp_category.id - } + vals = {"name": "5450534001716", "category_id": self.partner_id_gcp_category.id} with self.assertRaises(ValidationError): - self.partner.write({'id_numbers': [(0, 0, vals)]}) + 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)) + self.partner_id_gcp_category.validate_res_partner_gln(id_number=None) + ) From f7dffd28cc1122da6e8ceb9c3a8d93702abffeb7 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 5 Nov 2021 15:41:46 +0100 Subject: [PATCH 6/7] [IMP] partner_identification_gln: black, isort, prettier --- requirements.txt | 1 + .../odoo/addons/partner_identification_gln | 1 + setup/partner_identification_gln/setup.py | 6 ++++++ 3 files changed, 8 insertions(+) create mode 120000 setup/partner_identification_gln/odoo/addons/partner_identification_gln create mode 100644 setup/partner_identification_gln/setup.py diff --git a/requirements.txt b/requirements.txt index bcfab71c0..2d6c3b6a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ # generated from manifests external_dependencies email-validator +python-stdnum diff --git a/setup/partner_identification_gln/odoo/addons/partner_identification_gln b/setup/partner_identification_gln/odoo/addons/partner_identification_gln new file mode 120000 index 000000000..fa1c40dc9 --- /dev/null +++ b/setup/partner_identification_gln/odoo/addons/partner_identification_gln @@ -0,0 +1 @@ +../../../../partner_identification_gln \ No newline at end of file diff --git a/setup/partner_identification_gln/setup.py b/setup/partner_identification_gln/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_identification_gln/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From d179d7d22754749755be2f890149075a986d9f47 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 5 Nov 2021 15:46:55 +0100 Subject: [PATCH 7/7] partner_identification_gln: migrate to v14 --- partner_identification_gln/__manifest__.py | 4 ++-- .../readme/CONTRIBUTORS.rst | 1 + partner_identification_gln/tests/test_gln.py | 22 ++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/partner_identification_gln/__manifest__.py b/partner_identification_gln/__manifest__.py index 4aa0917a8..422123a8c 100644 --- a/partner_identification_gln/__manifest__.py +++ b/partner_identification_gln/__manifest__.py @@ -2,11 +2,11 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - "name": "Partner Identification Gln", + "name": "Partner Identification GLN", "summary": """ This addon extends "Partner Identification Numbers" to provide a number category for GLN registration""", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "license": "AGPL-3", "author": "Acsone S.A.,Odoo Community Association (OCA)", "website": "https://github.com/OCA/partner-contact", diff --git a/partner_identification_gln/readme/CONTRIBUTORS.rst b/partner_identification_gln/readme/CONTRIBUTORS.rst index 42b018f96..90915f05a 100644 --- a/partner_identification_gln/readme/CONTRIBUTORS.rst +++ b/partner_identification_gln/readme/CONTRIBUTORS.rst @@ -2,3 +2,4 @@ * Denis Roussel * Meyomesse Gilles * Bejaoui Souheil +* Simone Orsi diff --git a/partner_identification_gln/tests/test_gln.py b/partner_identification_gln/tests/test_gln.py index 6d3e5b7a7..1b9c76d14 100644 --- a/partner_identification_gln/tests/test_gln.py +++ b/partner_identification_gln/tests/test_gln.py @@ -6,19 +6,21 @@ from odoo.tests.common import SavepointCase class TestGLN(SavepointCase): - 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" + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + 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" ) - self.partner_id_category = pc + cls.partner_id_category = pc - pc_gcp = self.env.ref( - "partner_identification_gln." "partner_identification_gcp_number_category" + pc_gcp = cls.env.ref( + "partner_identification_gln.partner_identification_gcp_number_category" ) - self.partner_id_gcp_category = pc_gcp + cls.partner_id_gcp_category = pc_gcp def test_gln(self): # Good GLN