openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #20470
[Bug 1050648] Re: packaging EAN fails validation
** Changed in: openobject-addons
Status: Confirmed => In Progress
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1050648
Title:
packaging EAN fails validation
Status in OpenERP Addons (modules):
In Progress
Bug description:
OpenERP Server 6.1-1
Windows sbs 2008
If I try to save a packaging EAN for a product, I have an error
message about invalid EAN.
I assume that this error is generated because the server tries to
validate the EAN code with the same validator as EAN13 BUT (here is
the but) this EAN is 14 digits.
I made some changes to the product.py file
I added this:
def check_ean14(eancode):
if not eancode:
return True
if len(eancode) <> 14:
return False
try:
int(eancode)
except:
return False
oddsum=0
evensum=0
total=0
eanvalue=eancode
reversevalue = eanvalue[::-1]
finalean=reversevalue[1:]
for i in range(len(finalean)):
if is_pair(i):
oddsum += int(finalean[i])
else:
evensum += int(finalean[i])
total=(oddsum * 3) + evensum
check = int(10 - math.ceil(total % 10.0)) %10
if check != int(eancode[-1]):
return False
return True
and modify this line from this:
res = check_ean(pack.ean)
To this
res = check_ean14(pack.ean)
with this I skipped the 14 characters error of the EAN but I am not
sure the method for validation is the correct for packaging EAN.
After doing this change i was able to add packaging EAN for a product.
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1050648/+subscriptions
References