Skip to Content
Menu
This question has been flagged
1 Reply
3942 Views

In product creation form EAN13 barcode field is there. For this one sql constraint is there to check the format of ean13. I want to use this field, not only for ean13 also for other barcode formats. Please give me a solution. In my point of view, i want to remove the constraint. Please correct me if i am wrong.

files to replace the ean13 field in product.py.

.py files

from openerp.osv import fields, osv
import os.path
import fnmatch
from tools.translate import _

class product_extension(osv.osv):
    _inherit = "product.product"
    _columns = {
    'ean13': fields.char('Barcode', size=256, help="International Article Number used for product identification."),
    }
    def _check_ean_key(self, cr, uid, ids, context=None):
            return True


    _constraints = [(_check_ean_key, 'You provided an invalid "EAN13 Barcode" reference. You may use the "Internal Reference" field instead.', ['ean13'])]

*********************************************************************************************************************

.xml file

<record id="product_normal_form_view_extension_form1" model="ir.ui.view">
            <field name="name">product.normal.form.view.extension.form1</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                    <xpath expr="/form/sheet/notebook/page/group/group[2]/div/field[@name='ean13']" position="replace">
                        <field name="ean13" />
                        
                    </xpath>
           </field>
        </record>

 

Avatar
Discard
Best Answer

Look at https://www.odoo.com/apps/7.0/chricar_product_gtin/  and https://www.odoo.com/apps/7.0/product_gtin/

Avatar
Discard
Author

Thank you Med Said BARA, i got one problem. For example product p1 has upc code=12345, converted ean13 code 1234500000003, this code store in database. when i try to search with the code 12345 the required product not getting search.

Related Posts Replies Views Activity
1
Mar 15
3101
3
Mar 15
7309
0
Feb 25
1092
0
Dec 24
46
0
Dec 24
988