Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
7 Răspunsuri
7686 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

ur a master alot of thanks

Cel mai bun răspuns

I have added these modules, but am unable to view it when updating the module list?

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

many thanks

Autor Cel mai bun răspuns

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

Imagine profil
Abandonează

I updated my answer