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

What is the problem i face, If i remove the sql constraint for EAN13 field in product creation form?

By
samba
on 8/21/14, 9:45 AM 746 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>

 

0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 8/21/14, 12:52 PM

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.

samba
on 8/22/14, 5:14 AM

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

1 follower(s)

Stats

Asked: 8/21/14, 9:45 AM
Seen: 746 times
Last updated: 3/16/15, 8:10 AM