Skip to content

Commit

Permalink
[MIG] base_vat_optional_vies: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoBM committed Jan 26, 2023
1 parent d62e194 commit 12a9fd8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion base_vat_optional_vies/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "Optional validation of VAT via VIES",
"category": "Accounting",
"version": "15.0.1.0.3",
"version": "16.0.1.0.0",
"depends": ["base_vat"],
"data": ["views/res_partner_view.xml"],
"author": "Tecnativa," "Odoo Community Association (OCA)",
Expand Down
11 changes: 4 additions & 7 deletions base_vat_optional_vies/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@ class ResPartner(models.Model):

@api.model
def simple_vat_check(self, country_code, vat_number):
res = super(ResPartner, self).simple_vat_check(
country_code,
vat_number,
)
partner = self.env.context.get("vat_partner")
res = super().simple_vat_check(country_code, vat_number)
partner = self._context.get("vat_partner")
if partner:
partner.update({"vies_passed": False})
return res

@api.model
def vies_vat_check(self, country_code, vat_number):
partner = self.env.context.get("vat_partner")
partner = self._context.get("vat_partner")
if partner:
# If there's an exception checking VIES, the upstream method will
# call simple_vat_check and thus the flag will be removed
partner.update({"vies_passed": True})
res = super(ResPartner, self).vies_vat_check(country_code, vat_number)
res = super().vies_vat_check(country_code, vat_number)
if res is False:
if partner:
partner.update({"vies_passed": False})
Expand Down
2 changes: 1 addition & 1 deletion base_vat_optional_vies/tests/test_res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class TestResPartner(common.TransactionCase):
def setUp(self):
super(TestResPartner, self).setUp()
super().setUp()
self.company = self.env.user.company_id
self.company.vat_check_vies = True
self.partner = self.env["res.partner"].create(
Expand Down

0 comments on commit 12a9fd8

Please sign in to comment.