5
votes

Is it possible to extend search view and add more than one search boxes or check boxes for user’s convenience?

Right now there is only one search box and some time user doesn't want to click on the search box and then type and then filter or select a custom filter from the filter from filter plugin.It will be quick if I can add check boxes.

2
Yes, it's possible. You can extend it like a view.qvpham
@Ancient But, Where you want to add that checkbox in the search view. so, you can select any of one filter and that only will be available in the search box right?Chavada Viki
i wanto add it right under the search box or next to search box. Can you give me any example ?Ancient
@Ancient Checkboxes to do what? How would this work any differently than the standard Filters or Group By features?travisw
i know they will work same as filters or groups, but i want to give it a try just wanted to created checkbox and see if that's possible or notAncient

2 Answers

0
votes

Here is an example of extending odoo's search view:

odoo.define('modulename.makesearch', function (require) {
"use strict";
var searchView = require('web.SearchView');
var search_filters = require('web.search_filters');
var search_inputs = require('web.search_inputs');
var Widget = require('web.Widget');
var FavoriteMenu = require('web.FavoriteMenu');
var FilterMenu = require('web.FilterMenu');
var GroupByMenu = require('web.GroupByMenu');
var Model = require('web.DataModel');

var SearchFilterButton = searchView.include({
    init: function(parent, dataset, view_id, defaults, options) {
        this._super.apply(this, arguments);
        this.parent = parent;
    },
    view_loaded: function (r) {},
 });
 });
 //Here in view loaded function I wrote the definitions I need.
 //Here you write your own.

If you need to make changes on tree and kanban view you have to extend them also like above. If need to add a new search box you can extend the tree template from web and make proper changes.

-1
votes

Just extend the search view like every other view and add predefined filters like this: ( see "view_res_partner_filter" for example )

...
<field name="arch" type="xml">
...
<filter string="My First Value" domain="[('my_field','=', 'my_first_value')]"/>
<filter string="My Second Value" domain="[('my_field','=', 'my_second_value')]"/>
...
</field>

These predefined Filters will appear under "Filters" below the "search box" and can then be toggled by clicking ( much like your prefered behaviour with checkboxes )

If you insist on using checkboxes you will have to do a lot of work like changing the respective Qweb Templates as well as modifying the respective JS File ( see "Burmese pythis"'s Answer ) So I'd prefer this solution if time or cost matter to you.