From 2720eb84eeeb9fe4b41ef81bd505c4f2857c416d Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 11 Dec 2017 17:17:08 +0100 Subject: [PATCH] [FIX] website_portal: Verification of vat number in EU country We have problems when trying to validate our EU VAT report because some vat number are wrongly encoded in Odoo. There are 2 problems: 1) We use vatnumber library to check the validity of the VAT number entered by the user on website. That library removes the following characters '.' and '-' in order to perform the check and thus can return True for a number like 123.123.123.13 or -123-3454-34 And those VAT number are then saved in our database but are rejected by the state as VAT number should only contains alphanumeric character -> Solution: prevent entering vat number with other characters than alphanumeric for users that are located in EUROPE! 2) Usually VAT is prefixed by country code, however some people in europe managed to bypass the system by prefixing their VAT number with CC instead of their country code, CC is consider valid in odoo (it means Country Code) but is not a valid European country code in general, which means that those people that should have pay some tax have not. Which is a huge problem. -> Solution: prevent the use of CC as country code by the user when entering a vatnumber only if the user country is in EUROPE! source: https://en.wikipedia.org/wiki/VAT_identification_number opw:785443 --- addons/website_portal/controllers/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/website_portal/controllers/main.py b/addons/website_portal/controllers/main.py index 117e0f7dba7..e5bf6b12ef1 100644 --- a/addons/website_portal/controllers/main.py +++ b/addons/website_portal/controllers/main.py @@ -105,6 +105,8 @@ class website_account(http.Controller): # vat validation if data.get("vat") and hasattr(request.env["res.partner"], "check_vat"): + if data.get("country_id"): + data["vat"] = request.env["res.partner"].fix_eu_vat_number(int(data.get("country_id")), data.get("vat")) if request.website.company_id.sudo().vat_check_vies: # force full VIES online check check_func = request.env["res.partner"].vies_vat_check