Commit Graph
8 Commits
Author SHA1 Message Date
Ricardo Gomes Rodrigues (rigr)andDaniel Reis 88b4431c1c [FIX] base_vat: only use VIES service for company VAT numbers
Some countries, such as Portugal, persons also have VAT-like tax
numbers, that can be used in invoices, just like company VAT numbers
can.

However, the VIES service does not work for these person VAT numbers,
only for companies.

This fix ensures that VIES validation is only used for companies.

closes odoo/odoo#80521

X-original-commit: 87028f8b08628b8c643d84b0c19810470f540533
Signed-off-by: William André (wan) <wan@odoo.com>
Co-authored-by: Daniel Reis <dreis.pt@hotmail.com>
Co-authored-by: Ricardo Gomes Rodrigues (rigr) <rigr@odoo.com>
2021-11-29 13:09:47 +00:00
oco-odoo eaf5d86fe7 [FIX] base_vat: patch orm limitation
https://github.com/odoo/odoo/pull/68253 fixed a bug in check_vat that caused it not to run any check when called on a partner with no country.

However, doing this caused another issue because of an ORM limitation: when writing vat and country_id with a single write() on the res.company, two distinct write are triggered on the related res.partner, one for each field. Both those write trigger the check_vat constraint.

Depending on the order in which the keys of the dictionnary passed to res.company's write were ordered, country_id could or could not be written before vat. If vat was written first and did not start with a country code, the write() on res.partner failed the constraint, because country_id wasn't set yet. This was wrong, but used to pass as there was no country_id on the partner, before https://github.com/odoo/odoo/pull/68253 fixed that.

To circumvent the issue, we now allow entering any vat number without performing any check if it does not start with a country code and no country_id is set on the partner.

closes odoo/odoo#69243

X-original-commit: 7036b671228fdb5986b4f62a610a2e4d4132b8b1
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-04-14 10:29:00 +00:00
oco-odoo e68873fe89 [FIX] base_vat: Don't always pass VAT check when validating the VAT of a partner without country_id
Before this, when making a partner without any country_id, any VAT could be set to it, which was inconsistent with the module's purpose.

closes odoo/odoo#68815

X-original-commit: 72606f14d0c1d86d7a205fd29aec8d66d3e98678
Related: odoo/enterprise#17505
Signed-off-by: Cedric Snauwaert (csn) <csn@openerp.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-04-07 09:46:58 +00:00
wan 5783642ee4 [FIX] base_vat: not called at all
The function was wrongly imported and used, and it was hidden by a
generic catching of all exceptions.
The return value and some legit exceptions were also badly handled:
* The return value was always thruthy as it returns an object containing
information about the check.
* Exceptions can be raised if the format is not correct. In that case,
we don't want to go to the simple vat check.

Fixes #64897
opw-2451951

closes odoo/odoo#66522

X-original-commit: e711f359fef7ed4c37cb26d3946744e140bf00e0
Signed-off-by: William André (wan) <wan@odoo.com>
2021-02-19 09:50:24 +00:00
Adrian Torres 5952928b42 [REM] *: remove various unused import shims
Before this commit, a lot of leftover import shims existed in the
codebase for py2-py3 compatibility, these are no longer needed since
Odoo 13.0+ doesn't support Python 2 anymore and is (finally) in EOL.

With this commit, these shims are dropped, making the code cleaner,
easier to read and with one less dependency.

Queue -> queue -> py2-py3 compatibility
xmlrpclib -> xmlrpc.client -> py2-py3 compatibility
ConfigParser -> configparser -> py2-py3 compatibility
itertools.izip_longest -> itertools.zip_longest -> py2-py3 compatibility
urllib -> urllib.request -> py2-py3 compatibility
__builtins__ -> builtins -> py2-py3 compatibility
_winreg -> winreg -> py2-py3 compatibility

mock -> unittest.mock -> merged into CPython

The debian/fedora packages and requirements.txt have been updated accordingly

closes odoo/odoo#44601

Related: odoo/enterprise#8141
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-04-01 12:45:40 +00:00
Andrea Grazioso (agr-odoo) 9d790bfb5a [FIX] base_vat: skip compacting if not vat of the country
Create a new contact with:
- Name [DEMO]
- VAT RORO790707I47
- Country Mexico

An error inform the user that the vat is not valid, this happens because
the vat number is recognized as romanian and compacted before passing
to actual vat checking. Skip the check if the country of the new
partner does not match what is detected on the vat, assuming the user
know what he/she is doing

opw-2218491

closes odoo/odoo#48273

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-03-30 06:18:34 +00:00
Martin Trigaux b53614fcc5 [FIX] base_vat: apply child changes before propagation
The synchronisation of commercial_partner_id was introduced at
0d68acff8e as a way to ensure the value is always correct.
The order or the operation was not important though.

This synchronisation has a side effect in the following scenario:

0. install base_vat
1. disable vat_check_vies in the settings
2. set an invalid VAT number on a company with at least one contact
3. enable vat_check_vies in the settings
4. correct the VAT number on the company with a valid one
--> an error was raised for an invalid VAT number on the contact

This is because the commercial_partner_id synchronisation is done
before the update of the VAT number. Even if the value has not
changed, this triggers the check_vat method.

Invert both instructions

Courtesy of Wolfgang Taferner

Closes odoo/odoo#43065
Closes odoo/odoo#42973

closes odoo/odoo#47543

X-original-commit: d9b2605eadc129924d085fffc4056d777cfbbbeb
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-03-13 08:20:32 +00:00
fw-bot eaa094285e [FIX] l1n_pe: forward-port of fixes to l10n_pe
base_vat: Correct management of the check of peruvian VAT without prefix.
l10n_pe: Correct income account the last one is not correct.
l10n_pe: Forced Round globally for peruvian companies once l10n_pe is
installed, and with the onchange.
l10n_pe: For peruvian companies it does not make sense a sequence per
year and the year in the prefix is incorrect, we must force XXX- as
a sequence prefix.

closes odoo/odoo#38854

Forward-port-of: #38764
Signed-off-by: Josse Colpaert <jco@openerp.com>
2019-10-16 11:37:28 +00:00