Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing from upstream OCA/partner-contact (15.0) #1137

Merged
merged 20 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ addon | version | maintainers | summary
[partner_contact_personal_information_page](partner_contact_personal_information_page/) | 15.0.1.0.0 | | Add a page to contacts form to put personal information
[partner_contact_role](partner_contact_role/) | 15.0.1.0.0 | | Add roles to partners.
[partner_country_lang](partner_country_lang/) | 15.0.1.0.0 | [![victoralmau](https://github.com/victoralmau.png?size=30px)](https://github.com/victoralmau) | Partner language according country
[partner_data_vies_populator](partner_data_vies_populator/) | 15.0.1.0.0 | | Using VIES webservice, name and address information will be fetched and added to the partner.
[partner_deduplicate_acl](partner_deduplicate_acl/) | 15.0.1.2.1 | | Contact deduplication with fine-grained permission control
[partner_deduplicate_by_ref](partner_deduplicate_by_ref/) | 15.0.1.0.0 | | Deduplicate Contacts by reference
[partner_deduplicate_by_website](partner_deduplicate_by_website/) | 15.0.1.0.0 | | Deduplicate Contacts by Website
Expand Down
105 changes: 105 additions & 0 deletions partner_data_vies_populator/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
===========================
Partner Data VIES Populator
===========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6994744255bbf82abcfceab1c7da697c11b24d735df5bd845fa7208b6794ca1c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/15.0/partner_data_vies_populator
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-15-0/partner-contact-15-0-partner_data_vies_populator
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to create the partners (companies) based on their VAT number.
Name and address of the partner will automatically be completed via VIES Webservice.

VIES Service (based on stdnum python)
http://ec.europa.eu/taxation_customs/vies/vieshome.do

Unfortunately, VIES doesn't return a structured address but just a one-line address that aggregate street, zip and city. So, when you use this module to create a partner, the *City* and *Zip* fields will be left empty ; the *Street* field will contain the one-line address.

**Table of contents**

.. contents::
:local:

Installation
============

This module require the `python-stdnum <https://pypi.org/project/python-stdnum/>`_ librairy. As Odoo itself depend on this librairy, it should already be installed on your system.

Usage
=====

When changing a company partner VAT number, this module will try to fetch the partner data from VIES webservice, if available on VIES will update the name, address and country.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_data_vies_populator%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* NextERP Romania
* Forest and Biomass Romania

Contributors
~~~~~~~~~~~~

* `NextERP Romania <https://www.nexterp.ro>`_:

* Fekete Mihai <[email protected]>

* `Forest and Biomass Romania <https://www.forbiom.eu/>`_

* `Akretion <https://akretion.com/>`_ :

* Alexis de Lattre <[email protected]>

* `Noviat <https://www.noviat.com/>`_ :

* Jeremy Didderen <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/15.0/partner_data_vies_populator>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions partner_data_vies_populator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions partner_data_vies_populator/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2015 Forest and Biomass Romania
# Copyright (C) 2020 NextERP Romania
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Partner Data VIES Populator",
"summary": "Using VIES webservice, name and address information will "
"be fetched and added to the partner.",
"version": "15.0.1.0.0",
"category": "Customer Relationship Management",
"author": "NextERP Romania,"
"Forest and Biomass Romania,"
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"license": "AGPL-3",
"depends": ["base_vat"],
"external_dependencies": {"python": ["python-stdnum"]},
"installable": True,
}
41 changes: 41 additions & 0 deletions partner_data_vies_populator/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_data_vies_populator
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-09-28 10:07+0000\n"
"Last-Translator: Claude R Perrin <[email protected]>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: partner_data_vies_populator
#: model:ir.model,name:partner_data_vies_populator.model_res_partner
msgid "Contact"
msgstr "Contact"

#. module: partner_data_vies_populator
#: code:addons/partner_data_vies_populator/models/res_partner.py:0
#, python-format
msgid ""
"Failed to query VIES.\n"
"Technical error: %s."
msgstr ""
"Erreur pendant l'interrogation VIES.\n"
"Erreur technique : %s."

#~ msgid "Display Name"
#~ msgstr "Nom affiché"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Dernière modification le"
27 changes: 27 additions & 0 deletions partner_data_vies_populator/i18n/partner_data_vies_populator.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_data_vies_populator
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: partner_data_vies_populator
#: model:ir.model,name:partner_data_vies_populator.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_data_vies_populator
#: code:addons/partner_data_vies_populator/models/res_partner.py:0
#, python-format
msgid ""
"Failed to query VIES.\n"
"Technical error: %s."
msgstr ""
28 changes: 28 additions & 0 deletions partner_data_vies_populator/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_data_vies_populator
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"

#. module: partner_data_vies_populator
#: model:ir.model,name:partner_data_vies_populator.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_data_vies_populator
#: code:addons/partner_data_vies_populator/models/res_partner.py:0
#, python-format
msgid ""
"Failed to query VIES.\n"
"Technical error: %s."
msgstr ""
28 changes: 28 additions & 0 deletions partner_data_vies_populator/i18n/pt_PT.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_data_vies_populator
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: pt_PT\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"

#. module: partner_data_vies_populator
#: model:ir.model,name:partner_data_vies_populator.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_data_vies_populator
#: code:addons/partner_data_vies_populator/models/res_partner.py:0
#, python-format
msgid ""
"Failed to query VIES.\n"
"Technical error: %s."
msgstr ""
1 change: 1 addition & 0 deletions partner_data_vies_populator/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner
66 changes: 66 additions & 0 deletions partner_data_vies_populator/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright (C) 2015 Forest and Biomass Romania
# Copyright (C) 2020 NextERP Romania
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import logging

from odoo import _, api, models
from odoo.exceptions import UserError

_logger = logging.getLogger(__name__)

try:
from stdnum.eu.vat import check_vies
except ImportError:
_logger.debug("Cannot import check_vies method from python stdnum.")


class ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def _get_vies_data(self, vat, raise_if_fail=False):
res = {}
try:
result = check_vies(vat)
except Exception as e:
_logger.warning("Failed to query VIES: %s" % e)
if raise_if_fail:
raise UserError(
_("Failed to query VIES.\nTechnical error: %s.") % e
) from None
return res
if result.valid and result.name:
res["vat"] = vat
# Update partner name if listed on VIES
if result.name != "---":
res["name"] = result.name.upper()
# Update partner address if listed on VIES
if result.address != "---":
res["street"] = (
result.address.replace("\n", " ").replace("\r", "").title()
)
# Get country by country code
country = self.env["res.country"].search(
[("code", "ilike", result.countryCode)]
)
if country:
res["country_id"] = country[0].id
return res

@api.onchange("vat")
def vies_vat_change(self):
eu_group = self.env.ref("base.europe", raise_if_not_found=False)
if eu_group:
for partner in self:
if not partner.vat or not partner.is_company:
continue
vat = partner.vat.strip().upper()
vat_country, vat_number = self._split_vat(vat)
vat_country = vat_country.upper()
eu_countries = eu_group.country_ids.mapped("code")
if vat_country and vat_country not in eu_countries:
continue
result = self._get_vies_data(vat)
if result:
partner.update(result)
13 changes: 13 additions & 0 deletions partner_data_vies_populator/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* `NextERP Romania <https://www.nexterp.ro>`_:

* Fekete Mihai <[email protected]>

* `Forest and Biomass Romania <https://www.forbiom.eu/>`_

* `Akretion <https://akretion.com/>`_ :

* Alexis de Lattre <[email protected]>

* `Noviat <https://www.noviat.com/>`_ :

* Jeremy Didderen <[email protected]>
7 changes: 7 additions & 0 deletions partner_data_vies_populator/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module allows you to create the partners (companies) based on their VAT number.
Name and address of the partner will automatically be completed via VIES Webservice.

VIES Service (based on stdnum python)
http://ec.europa.eu/taxation_customs/vies/vieshome.do

Unfortunately, VIES doesn't return a structured address but just a one-line address that aggregate street, zip and city. So, when you use this module to create a partner, the *City* and *Zip* fields will be left empty ; the *Street* field will contain the one-line address.
1 change: 1 addition & 0 deletions partner_data_vies_populator/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module require the `python-stdnum <https://pypi.org/project/python-stdnum/>`_ librairy. As Odoo itself depend on this librairy, it should already be installed on your system.
1 change: 1 addition & 0 deletions partner_data_vies_populator/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When changing a company partner VAT number, this module will try to fetch the partner data from VIES webservice, if available on VIES will update the name, address and country.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading