Skip to Content
Menu
This question has been flagged
1 Reply
2708 Views

currently i am using below code..but not able to display search fields in tree view.

<t t-name="SearchRow">
<tr id="search_row" class=".sky-search">

<th t-if="list_view">
<!--- For list view -->
<th></th>
</th>
<th t-if="extra_column"/>
<t t-foreach="sky_fields" t-as="column">
<t t-esc="column"/>
<th t-if="column[3] == 'handle'"/>
<th t-if="column[2]=='date' or column[2]=='datetime'">
<div style="width:290px;display: -webkit-inline-box;">
<div class="leftcol">
<input style="height: 30px;" t-att-name="column[0]" t-att-id="column[0]+'start_date'"
placeholder="From" class="start_date" size="10" type="text"/>
</div>
<div class="rightcol">
<input style="height: 30px;" t-att-name="column[0]" t-att-id="column[0]+'end_date'"
placeholder="To"
class="end_date" size="10" type="text"/>
</div>
</div>
</th>

<th t-if="!(column[2]=='date' or column[2]=='datetime' or column[2]=='selection' or column[2]=='many2many' ) and column[3] != 'handle' and column[2]!='many2many'">

<div class="input-group">
<input style="height: 30px;width:100px;" t-att-name="column[0]" t-att-id="column[0]"
t-att-placeholder="column[1]" class="search_field" size="10" type="text"/>
<span class="input-group-btn">
<li class="o_text_filter">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
<span class="fa fa-filter"/></button>
<input type="hidden" id="filtertext"/>
<ul class="dropdown-menu o_quickadd_dropdown" role="menu">
<li class="rmItem rmFirst"><a href="#" class="rmLink" style="width: 153px;">
<span class="rmText"> No filter</span></a></li>
<li class="rmItem " style=""><a href="#" data-action="contains_filter" class="rmLink" style="width: 153px;">
<span class="rmText"> Contains</span></a></li>
<li class="rmItem " style=""><a href="#" class="rmLink" style="width: 153px;">
<span class="rmText"> Starts with</span></a>
</li>
<li class="rmItem "><a href="#" class="rmLink" style="width: 153px;">
<span class="rmText"> Equal to</span></a>
</li>
<li class="rmItem "><a href="#" class="rmLink" style="width: 153px;">
<span class="rmText"> Not equal to</span></a>
</li>
<li class="rmItem "><a href="#" class="rmLink" style="width: 153px;">
<span class="rmText"> Greater than</span></a></li>
<li class="rmItem rmLast"><a href="#" class="rmLink" style="width: 153px;">
<span class="rmText"> Less than</span></a>
</li>
</ul>
</li>
</span>
</div>
</th>
<th t-if="column[2]=='selection'">
<select style="width:120px;" class="selection_field" t-att-id="column[0]" t-att-name="column[0]">
<option/>
<t t-foreach="column[3]" t-as="selection_value">
<option t-att-value="selection_value[0]"><t t-esc="selection_value[1]" /></option>
</t>
</select>
</th>
<th t-if="(column[2]=='many2many')">
<div class="input-group">
<input style="height: 30px;width:100px;" t-att-name="column[0]" t-att-id="column[0]"
t-att-placeholder="column[1]" class="search_field" size="10" type="text"/>
<span class="input-group-btn">
<li class="o_text_filter">
</li></span></div>



</th>
</t>
</tr>
</t>

my js code

if (sky_fields.length > 0) {
self.$search_row = $(QWeb.render('SearchRow', {
'sky_fields': sky_fields,
'list_view': list_view,
'extra_column': extra_column
}))

self.$search_row.find('.start_date').datetimepicker(datepickers_options);
self.$search_row.find('.end_date').datetimepicker(datepickers_options);

self.$search_row.find('.search_field').keypress(function(e) {
if(e.keyCode == 13){
var sd = $(this).text();
self.$search_row.find('#filtertext').val(sd.trim());
self.advanced_search();
}
});

self.$search_row.find('.o_quickadd_dropdown li').on('click', function() {

var sd = $(this).text();
self.$search_row.find('#filtertext').val(sd.trim());
self.advanced_search();


});
self.$search_row.find('.selection_field').on('change', function() {
self.advanced_search();
});
self.$search_row.find('.start_date').keypress(function(e) {
if (e.which == 13) {
self.advanced_search();
return false; //<---- Add this line
}
});
self.$search_row.find('.end_date').keypress(function(e) {
if (e.which == 13) {
self.advanced_search();
return false; //<---- Add this line
}
});
if (self.fields_view.model != 'activity.crm') {
self.$search_row.appendTo(self.$('#bullseye'));
}


}
}
Avatar
Discard
Best Answer

Hello,

you can get some ideas from below mentioned module that module is for odoo v10

https://apps.odoo.com/apps/modules/10.0/bi_advanced_search_tree/


regards

Avatar
Discard