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>