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>