Getting the error "Warning Error occurred while validating the field(s) ean13: Error: Invalid ean code"

Asked by Bushair

Hi,
I was trying to create a new product using MainMenu->Products->NewProduct
The value entered in EAN13 field is

EAN13 :01-223456-678

But when i tried to save this product ,am getting the below error

Warning

 Error occurred while validating the field(s) ean13: Error: Invalid ean code

How to resolve this error?

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Bushair
Solved:
Last query:
Last reply:
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#1

Hello,

It is allowed only some specific format only and used only integer number not any special character like '-' and not any other character allow.
You can check some specific example for testing purpose from following link:
http://www.officialeancode.com/label_printing.html

used this eg :0012345678905, It will be saved and will not give you error.

Check the code logic which is used for constraint:
Product/product.py , Approximate line no : 452 and code is :

    def _check_ean_key(self, cr, uid, ids):
        for partner in self.browse(cr, uid, ids):
            if not partner.ean13:
                continue
            if len(partner.ean13) <> 13:
                return False
            try:
                int(partner.ean13)
            except:
                return False
            sum=0
            for i in range(12):
                if is_pair(i):
                    sum += int(partner.ean13[i])
                else:
                    sum += 3 * int(partner.ean13[i])
            check = int(math.ceil(sum / 10.0) * 10 - sum)
            if check != int(partner.ean13[12]):
                return False
        return True

    _constraints = [(_check_ean_key, 'Error: Invalid ean code', ['ean13'])]

Hope this will help you.

Thanks.

Revision history for this message
Bushair (bushairka) said :
#2

Hi,
The issue is resolved now..
Thanks