diff --git a/l10n_ro_partner_create_by_vat_button/README.rst b/l10n_ro_partner_create_by_vat_button/README.rst index 2433e03d..47a33987 100644 --- a/l10n_ro_partner_create_by_vat_button/README.rst +++ b/l10n_ro_partner_create_by_vat_button/README.rst @@ -7,7 +7,7 @@ Romania - Partner Create by VAT Button !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:b7ea1a713e84cf52c890e1bdf285d0637578a02033e543e334cf0d89a356a441 + !! source digest: sha256:921a3276d297d5675bfb54ca95b8118a4f3de208aa9c18ddc39467cb19a3935b !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -22,7 +22,7 @@ Romania - Partner Create by VAT Button |badge1| |badge2| |badge3| - - Adaugare buton in ecran pentru recitire date ANF + - Adaugare buton in ecran pentru recitire date ANAF - **Table of contents** diff --git a/l10n_ro_partner_create_by_vat_button/__manifest__.py b/l10n_ro_partner_create_by_vat_button/__manifest__.py index f62db379..59e4b977 100644 --- a/l10n_ro_partner_create_by_vat_button/__manifest__.py +++ b/l10n_ro_partner_create_by_vat_button/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Romania - Partner Create by VAT Button", "license": "AGPL-3", - "version": "15.0.1.0.6", + "version": "15.0.1.0.7", "author": "Dorin Hongu," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/l10n-romania", "category": "Localization", diff --git a/l10n_ro_partner_create_by_vat_button/models/res_partner.py b/l10n_ro_partner_create_by_vat_button/models/res_partner.py index 4a592af6..dced2750 100644 --- a/l10n_ro_partner_create_by_vat_button/models/res_partner.py +++ b/l10n_ro_partner_create_by_vat_button/models/res_partner.py @@ -60,10 +60,19 @@ def get_partner_name_from_vies(self): client = Client("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl") # Make a request to the VIES service to check the VAT number - response = client.service.checkVat(countryCode=self.name[:2], vatNumber=self.name[2:]) + if not self.vat.isdigit(): + vat_number = self.vat[2:] + country_code = self.vat[:2] + elif self.country_id: + vat_number = self.vat + country_code = self.country_id.code + else: + raise UserError(_("Please add the country code to the vat number or country field")) + + response = client.service.checkVat(countryCode=country_code, vatNumber=vat_number) if response.valid: - self.vat = self.name - self.country_id = self.env["res.country"].search([("code", "ilike", self.name[:2].lower())])[0].id + self.vat = vat_number + self.country_id = self.env["res.country"].search([("code", "ilike", country_code)])[0].id self.name = response.name self.street = response.address else: diff --git a/l10n_ro_partner_create_by_vat_button/readme/DESCRIPTION.rst b/l10n_ro_partner_create_by_vat_button/readme/DESCRIPTION.rst index 58d0c79d..c5b1bae2 100644 --- a/l10n_ro_partner_create_by_vat_button/readme/DESCRIPTION.rst +++ b/l10n_ro_partner_create_by_vat_button/readme/DESCRIPTION.rst @@ -1,2 +1,2 @@ - - Adaugare buton in ecran pentru recitire date ANF + - Adaugare buton in ecran pentru recitire date ANAF - diff --git a/l10n_ro_partner_create_by_vat_button/static/description/index.html b/l10n_ro_partner_create_by_vat_button/static/description/index.html index 57f5a133..4b5895a9 100644 --- a/l10n_ro_partner_create_by_vat_button/static/description/index.html +++ b/l10n_ro_partner_create_by_vat_button/static/description/index.html @@ -368,12 +368,12 @@

Romania - Partner Create by VAT Button

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:b7ea1a713e84cf52c890e1bdf285d0637578a02033e543e334cf0d89a356a441 +!! source digest: sha256:921a3276d297d5675bfb54ca95b8118a4f3de208aa9c18ddc39467cb19a3935b !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 dhongu/l10n-romania