Browse Source

[MIG] Partner Identification Gln v10

12.0
gilles 7 years ago
committed by BT-aestebanez
parent
commit
e3483be0f0
  1. 5
      partner_identification_gln/README.rst
  2. 3
      partner_identification_gln/__init__.py
  3. 6
      partner_identification_gln/__manifest__.py
  4. 28
      partner_identification_gln/data/partner_identification_gln.xml
  5. 4
      partner_identification_gln/models/__init__.py
  6. 7
      partner_identification_gln/models/partner.py
  7. 4
      partner_identification_gln/tests/__init__.py
  8. 43
      partner_identification_gln/tests/test_gln.py

5
partner_identification_gln/README.rst

@ -20,10 +20,6 @@ This module depends on 'stdnum' python module
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/repo/github-com-oca-partner-contact-134 :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 Bug Tracker
=========== ===========
@ -44,6 +40,7 @@ Contributors
------------ ------------
* Denis Roussel <denis.roussel@acsone.eu> * Denis Roussel <denis.roussel@acsone.eu>
* Meyomesse Gilles <meyomesse.gilles@gmail.com>
Maintainer Maintainer
---------- ----------

3
partner_identification_gln/__init__.py

@ -1,2 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models

6
partner_identification_gln/__openerp__.py → partner_identification_gln/__manifest__.py

@ -1,13 +1,13 @@
# -*- coding: utf-8 -*- # -*- 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 (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Partner Identification Gln', 'name': 'Partner Identification Gln',
'summary': """ 'summary': """
This addon extends "Partner Identification Numbers" This addon extends "Partner Identification Numbers"
to provide a number category for GLN registration""", to provide a number category for GLN registration""",
'version': '8.0.1.0.0',
'version': '10.0.1.0.0',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'Acsone S.A.,Odoo Community Association (OCA)', 'author': 'Acsone S.A.,Odoo Community Association (OCA)',
'website': 'https://www.acsone.eu', 'website': 'https://www.acsone.eu',

28
partner_identification_gln/data/partner_identification_gln.xml

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="res.partner.id_category" id="partner_identification_gln_number_category">
<field name="name">GLN Identification Number</field>
<field name="code">gln_id_number</field>
<field name="validation_code"><![CDATA[failed = self.validate_res_partner_gln(id_number)]]></field>
</record>
<record model="res.partner.id_category" id="partner_identification_gcp_number_category">
<field name="name">GCP Identification Number</field>
<field name="code">gcp_id_number</field>
<field name="validation_code"><![CDATA[failed = self.validate_res_partner_gcp(id_number)]]></field>
</record>
</data>
</openerp>
<!-- Copyright 2016-2017 ACSONE SA/NV (<http://acsone.eu>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record model="res.partner.id_category" id="partner_identification_gln_number_category">
<field name="name">GLN Identification Number</field>
<field name="code">gln_id_number</field>
<field name="validation_code"><![CDATA[failed = self.validate_res_partner_gln(id_number)]]></field>
</record>
<record model="res.partner.id_category" id="partner_identification_gcp_number_category">
<field name="name">GCP Identification Number</field>
<field name="code">gcp_id_number</field>
<field name="validation_code"><![CDATA[failed = self.validate_res_partner_gcp(id_number)]]></field>
</record>
</odoo>

4
partner_identification_gln/models/__init__.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import partner from . import partner

7
partner_identification_gln/models/partner.py

@ -1,8 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016-2017 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).
import logging import logging
from openerp import api, models
from odoo import api, models
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
try: try:

4
partner_identification_gln/tests/__init__.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- 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 (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_gln from . import test_gln

43
partner_identification_gln/tests/test_gln.py

@ -2,35 +2,37 @@
# Copyright 2016 Acsone S.A. # Copyright 2016 Acsone S.A.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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): def test_gln(self):
# Good GLN # Good GLN
vals = {'name': '5450534001717',
vals = {'name': '5450534005852',
'category_id': self.partner_id_category.id '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] id_number = self.partner.id_numbers[0]
self.assertEqual(id_number.name, '5450534001717')
self.assertEqual(id_number.name, '5450534005852')
# Duplicate GLN # Duplicate GLN
vals = {'name': '5450534001717',
vals = {'name': '5450534005852',
'category_id': self.partner_id_category.id 'category_id': self.partner_id_category.id
} }
@ -44,6 +46,10 @@ class TestGLN(TransactionCase):
with self.assertRaises(ValidationError): 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))
def test_gcp(self): def test_gcp(self):
# Good GLN # Good GLN
vals = {'name': '545053', vals = {'name': '545053',
@ -68,3 +74,8 @@ class TestGLN(TransactionCase):
} }
with self.assertRaises(ValidationError): 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))
Loading…
Cancel
Save