|
@ -1,26 +1,24 @@ |
|
|
# Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com> |
|
|
# Copyright 2017 Grant Thornton Spain - Ismael Calvo <ismael.calvo@es.gt.com> |
|
|
# 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). |
|
|
|
|
|
|
|
|
from odoo.tests.common import SavepointCase |
|
|
|
|
|
from odoo.exceptions import ValidationError |
|
|
from odoo.exceptions import ValidationError |
|
|
|
|
|
from odoo.tests.common import SavepointCase |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestVatUnique(SavepointCase): |
|
|
class TestVatUnique(SavepointCase): |
|
|
@classmethod |
|
|
@classmethod |
|
|
def setUpClass(cls): |
|
|
def setUpClass(cls): |
|
|
super(TestVatUnique, cls).setUpClass() |
|
|
super(TestVatUnique, cls).setUpClass() |
|
|
cls.partner_model = cls.env['res.partner'] |
|
|
|
|
|
cls.partner = cls.partner_model.create({ |
|
|
|
|
|
'name': 'Test partner', |
|
|
|
|
|
'vat': 'ESA12345674' |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
cls.partner_model = cls.env["res.partner"] |
|
|
|
|
|
cls.partner = cls.partner_model.create( |
|
|
|
|
|
{"name": "Test partner", "vat": "ESA12345674"} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
def test_duplicated_vat_creation(self): |
|
|
def test_duplicated_vat_creation(self): |
|
|
with self.assertRaises(ValidationError): |
|
|
with self.assertRaises(ValidationError): |
|
|
self.partner_model.with_context(test_vat=True).create({ |
|
|
|
|
|
'name': 'Second partner', |
|
|
|
|
|
'vat': 'ESA12345674' |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
self.partner_model.with_context(test_vat=True).create( |
|
|
|
|
|
{"name": "Second partner", "vat": "ESA12345674"} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
def test_duplicate_partner(self): |
|
|
def test_duplicate_partner(self): |
|
|
partner_copied = self.partner.copy() |
|
|
partner_copied = self.partner.copy() |
|
|