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

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

By
Herman
on 4/9/15, 7:29 AM 654 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",
        domain=[('attribute_id','=','Height')])
    
    class Sale_order_line(models.Model):
        _inherit = 'sale.order.line'
        width_id= fields.Many2one("product.attribute.value","Width",
        domain=[('attribute_id','=','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, 
    			context['material_id'],['materialoptions_id'])
    			
    			args = [('categ_id','=',productobj['materialoptions_id'][0])] + args
    		return super(product_product, self).search(cr, uid, args,  offset, limit, 
    		order, context=context, count=count)

And...

    <openerp>
        <data>
            <!-- 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"/>
                	</field>
                    <notebook position="inside">
                        <page string="Pale Point">
                            <group>
                                <field name="palepoint"/>
                               
                            </group>
                        </page>
                    </notebook>
                </field>
            </record>
            
        
    		
    		<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"/>
    				</field>
    				<xpath expr="//field[@name='product_id']" position="after">
    					<field name="height_id"/>
    				</xpath>
    				<xpath expr="//field[@name='product_id']" position="after">
    					<field name="width_id"/>
    				</xpath>
    				<xpath expr="//field[@name='product_id']" position="after">
    					<field name="product_type_id"/>
    				</xpath>
    				<xpath expr="//field[@name='product_type_id']" position="attributes">		
    					<attribute name="context">{'material_id': parent.material_id}</attribute>
    				</xpath>
    			</field>
    		</record>
        </data>
    </openerp>

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: 4/9/15, 7:29 AM
Seen: 654 times
Last updated: 4/9/15, 8:05 AM