Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chienandalu committed Jun 30, 2017
1 parent 5681676 commit 66d364d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 2 additions & 8 deletions base_vat_optional_vies/models/res_partner.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# License AGPL-3: Tecnativa S.L. - Antonio Espinosa
# See README.rst file on addon root folder for more details
# Copyright 2015 Tecnativa - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import logging
import re
Expand Down Expand Up @@ -38,12 +38,6 @@ def check_vat(self):
if not partner.validate_vat():
raise UserError(partner._construct_constraint_msg())

@api.multi
def button_check_vat(self):
if not self.validate_vat():
raise UserError(self._construct_constraint_msg())
return True

def _split_vat(self, vat, country=False):
"""
@summary: Split Partner vat into country_code and number
Expand Down
13 changes: 12 additions & 1 deletion base_vat_optional_vies/tests/test_res_partner.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2016 Tecnativa - Sergio Teruel
# Copyright 2016 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.tests.common import TransactionCase
Expand Down Expand Up @@ -50,10 +51,20 @@ def _test_validate_vat(self, cases):
# ('de222070543', 'DE222070543', True),
# # Valid VATs don't signed up in VIES
# ('DE253130868', 'DE253130868', False),
# ('esB87286357', 'ESB87286357', False),
# ('esA64970486', 'ESA64970486', False),
# )
# self._test_validate_vat(cases)

def test_validate_vat_vies_true(self):
""" Validate just one """
self.company.vat_check_vies = True
cases = (
# vat => vat, vies_passed
# VATs signed up in VIES
('ESB84718550', 'ESB84718550', True),
)
self._test_validate_vat(cases)

def test_validate_vat_no_vies(self):
"""
Validate VAT when company 'vat_check_vies' option is False
Expand Down

0 comments on commit 66d364d

Please sign in to comment.