Odoo Help


Odoo 8 Custom search only fires after "search more" is clicked

on 4/9/15, 7:29 AM 759 views

My custom search is overriding

OST /web/dataset/call_kw/product.template/fields_get

instead of

ST /web/dataset/call_kw/product.template/name_search 

here is my .py and view code. Thanks everyone

    from openerp import models, fields, api
    class product_template(models.Model):
    	_inherit = 'product.template'
    	palepoint = fields.Char("Pale Point", size=20)
    	materialoptions_id = fields.Many2one("product.category","Material Options")
    class Sale_order(models.Model):
        _inherit = 'sale.order'
        material_id= fields.Many2one("product.template","Material",
        domain=[('categ_id.name','=','Raw Material')])
    class Sale_order_line(models.Model):
        _inherit = 'sale.order.line'
        height_id= fields.Many2one("product.attribute.value","Height",
    class Sale_order_line(models.Model):
        _inherit = 'sale.order.line'
        width_id= fields.Many2one("product.attribute.value","Width",
    class Sale_order_line(models.Model):
        _inherit = 'sale.order.line'
        product_type_id= fields.Many2one("product.template","Product Type")
    class product_product(models.Model):
    	_inherit = 'product.template'
    	def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
    		print "SHE FIRES! ===============> BOOM!!"
    		if context is None:
    			context = {}
    		if context.get('material_id'):
    			productobj = self.pool.get('product.template').read(cr, uid, 
    			args = [('categ_id','=',productobj['materialoptions_id'][0])] + args
    		return super(product_product, self).search(cr, uid, args,  offset, limit, 
    		order, context=context, count=count)


            <!-- Add instructor field to existing view -->
            <record model="ir.ui.view" id="partner_palepoint_form_view">
                <field name="model">product.template</field>
                <field name="inherit_id" ref="product.product_template_only_form_view"/>
                <field name="arch" type="xml">
                	<field name="list_price" position="after">
                		<field name="materialoptions_id"/>
                    <notebook position="inside">
                        <page string="Pale Point">
                                <field name="palepoint"/>
    		<record model="ir.ui.view" id="sale_view_form_view">        
                <field name="model">sale.order</field>
                <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>
                <field name="arch" type="xml">
    				<field name="partner_id" position="after">
    					<field name="material_id"/>
    				<xpath expr="//field[@name='product_id']" position="after">
    					<field name="height_id"/>
    				<xpath expr="//field[@name='product_id']" position="after">
    					<field name="width_id"/>
    				<xpath expr="//field[@name='product_id']" position="after">
    					<field name="product_type_id"/>
    				<xpath expr="//field[@name='product_type_id']" position="attributes">		
    					<attribute name="context">{'material_id': parent.material_id}</attribute>

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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/9/15, 7:29 AM
Seen: 759 times
Last updated: 4/9/15, 8:05 AM