Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to add Unique barcode number on product?

By
husam
on 3/31/14, 4:59 AM 1,716 views

how to add Unique barcode number on product in order to avoid having 2 different product with the same barcode number

0
Harsh Dhaduk
On 3/31/14, 11:35 AM

product->product.py

find class product.product add following code line no 588

_sql_constraints = [
        ('unique_product_barcode', 'unique(ean13)', 'Product Bar-Code  Must Be Unique .'),
     ]

upgrade this module Restart your server Settings->Installed Modules->find Products & Pricelists upgrade

OR

if you want to create separate module for this one follow this step

create one folder name should like

unique_product_barcode

inside this folder add __init__.py , __openerp__.py and yourmodule.py file

1) __init__.py

import unique_product

2) __openerp__.py

{
    'name': 'Product Unique Barcode',
    'version': '1.1',
    'author': 'Husam',
    'category': 'Sales Management',
    'depends': ['base', 'process', 'decimal_precision', 'mail'],
    'description': """
        Unique Barcode of Product 
    """,
    'data': [],
    'installable': True,
    'auto_install': False,     }

3) unique_product.py

from openerp.osv import fields,osv

class product_product(osv.osv):
    _inherit = 'product.product'
   _sql_constraints = [
        ('unique_product_barcode', 'unique(ean13)', 'Product Bar-Code  Must Be Unique .'),
     ]

product_product()

Restart Your OpenERP Go to Settings->Install Modules->find unique_product_barcode and install

ur a master alot of thanks

husam
on 3/31/14, 2:22 PM
0
husam
On 3/31/14, 10:51 AM

Thank you so much for your reply, but which python file, can you provide path?

I updated my answer

Prakash
on 3/31/14, 11:24 AM
0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 3/31/14, 5:30 AM

Add Unique Constraints in python file.

Create custom module

For Example create addons/barcode_unique Module

1) __init__.py file

import product

2) __openerp__.py file

{
    "name" :        "Product Barcode Unique",
    "version" :     "0.1",
    "category":     '',
    "description" : "Product",
    "author" :      "ERP",
    "depends" :     ["product"],
    "init_xml" :    [],
    "update_xml" :  [],
    "data": [],                         
    "css": [],                                
    "installable" : True,
    "active" :      False,

}

1) Create Product.py File add the below code

class product_product(osv.osv):
    _inherit = "product.product"

    _sql_constraints = [
            ('barcode_uniq', 'unique(ean13)', 'Bar-code  No must be unique !'),
         ]

Create the above Module and Install in openerp

many thanks

husam
on 3/31/14, 2:23 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/31/14, 4:59 AM
Seen: 1716 times
Last updated: 3/16/15, 8:10 AM