packaging EAN fails validation

Bug #1050648 reported by Rodrigo Nuno
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP R&D Addons Team 2

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.

Related branches

affects: openobject-server → openobject-addons
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Rodrigo Nuno ,

Currently EAN14 facility is not provided by us , if you want this facility then you can custumise
it.So its not a bug and I am closing this issue.

Thanks!!!

Changed in openobject-addons:
status: New → Invalid
Revision history for this message
Rodrigo Nuno (r-nayala) wrote :

Hello Jignesh.

EAN14 is not marked as that. In product/packaging it just says EAN and in the . This is one of the core and basic addons.

field name: EAN
length: 14 <-------------
relationship: product.packaging
Model: packaging
Type: base

This is EAN14 and openERP tries to validate it with EAN13 validation.

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

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:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Medium
status: Invalid → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
SnippetBucket.com (tta-openerp) wrote :

Hello,

This bug have been Fixed.

 * It has been Fixed in https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1050648-tta
 * Revision ID: <email address hidden>

  It will be available soon in trunk.

Thanks,
Tejas - tta

Changed in openobject-addons:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.