Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
7 Odpowiedzi
7689 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

ur a master alot of thanks

Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

many thanks

Autor Najlepsza odpowiedź

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

Awatar
Odrzuć

I updated my answer