← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 635265] Re: base_vat checks don't behave correctly with spaces and throw a server exception

 

Hello,

unless i'm wrong this case is jsut not possible because of the replace('
','') line 52 that will just remove all the spaces in the vat number.

52         vat_country, vat_number = vat[:2].lower(), vat[2:].replace('
', '')


I'm setting this bug as invalid, please correct me if i'm missing something. 

Thanks for your contribution

** Changed in: openobject-addons
       Status: Confirmed => Invalid

-- 
base_vat checks don't behave correctly with spaces and throw a server exception
https://bugs.launchpad.net/bugs/635265
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.

Status in OpenObject Addons Modules: Invalid

Bug description:
base_vat module uses the following expression to ensure all elements of a string are numeric:

try:
        int(vat)
except:
        return False

This is just wrong because vat (which is a string) may contain spaces at the beginning or end ('  123456') which will not throw an exception. The problem is that usually, after this check, the code continues as if each character was a number and the application can crash.

The attached patch adds a function 'all_numbers()' that is used to check this properly by using a regular expression.