5

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.

Kimchy
  • 501
  • 8
  • 24
Ancient
  • 3,007
  • 14
  • 55
  • 104
  • Yes, it's possible. You can extend it like a view. – qvpham Aug 21 '17 at 13:42
  • @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 Aug 21 '17 at 13:53
  • i wanto add it right under the search box or next to search box. Can you give me any example ? – Ancient Aug 21 '17 at 14:02
  • @Ancient Checkboxes to do what? How would this work any differently than the standard Filters or Group By features? – travisw Aug 21 '17 at 17:43
  • 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 not – Ancient Aug 21 '17 at 17:44
  • @Ancient Do you want to update or override the existing features/formatting? – travisw Aug 28 '17 at 18:03
  • I want the current search functionality to remain same and add extra check-boxes. – Ancient Aug 28 '17 at 18:08
  • @Ancient I think you will need to dive deeply into the `web/static/src/js/views/form_common.js` file to see what is happening in the `setup` file. The existing search buttons are in a `o_search_options` class element. – travisw Aug 29 '17 at 20:04
  • only the tree and kanban view has search – Hilar AK Aug 31 '17 at 03:41

2 Answers2

0

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.

Hilar AK
  • 1,655
  • 13
  • 25
-1

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.

Daniel A.
  • 1
  • 1