openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #15755
[Bug 1050648] Re: packaging EAN fails validation
Hello Rodrigo Nuno ,
Sorry for inconvenience and thanks for your reply.
I agree with you that currently EAN14 no checked with EAN13 and it's wrong.
also name "EAN" not "EAN14".
The EAN 14 code is used for traded goods. The code is always 14 numeric
digits long.
So I am confirming this issue for trunk.
Thanks for your contribution.
** Changed in: openobject-addons
Importance: Undecided => Medium
** Changed in: openobject-addons
Status: Invalid => Confirmed
** Changed in: openobject-addons
Assignee: (unassigned) => OpenERP R&D Addons Team 2 (openerp-dev-addons2)
--
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):
Confirmed
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