|
@ -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.' |
|
|
|
|
|
|
|
|
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') |
|
|
'partner_identification_gln_number_category') |
|
|
self.partner_id_category = pc |
|
|
|
|
|
|
|
|
cls.partner_id_category = pc |
|
|
|
|
|
|
|
|
pc_gcp = self.env.ref('partner_identification_gln.' |
|
|
|
|
|
|
|
|
pc_gcp = cls.env.ref('partner_identification_gln.' |
|
|
'partner_identification_gcp_number_category') |
|
|
'partner_identification_gcp_number_category') |
|
|
self.partner_id_gcp_category = pc_gcp |
|
|
|
|
|
|
|
|
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)) |