Aide

0

Hide fields in Filters And Group By

Avatar
Ibrahim Boudmir

Hi All, 
How to hide Fields in Filters and Group by in kanban, list, pivot.. views ? 

Thanks. 

2Commentaires
Avatar
Annuler
Avatar
Ibrahim Boudmir
-

that was only the Filters' part ;)

I prefered to join the answer for both cases ( Filters and Group By) in one post.

5Réponses
2
Avatar
Ibrahim Boudmir
Meilleure réponse

Answer: 

There are two parts : 
A- Filters : 

Please follow this link  : https://www.odoo.com/fr_FR/forum/aide-1/question/hide-filter-name-from-add-custom-filter-drop-down-147813#answer-147820.

B- Group by : 

In Odoo11, add a Js file to your module:  controlpanel.js

then paste this : 

odoo.define('module.ControlPanel', function (require) {
    'use strict';
    var ControlPanel = require('web.ControlPanel');
    ControlPanel.include({
        _update_search_view: function(searchview, is_hidden) {
            this._super.apply(this, arguments);
            if(searchview){
                this._rpc({
                        model: 'your.model.name',
                        method: 'the_function_that_returns_list_of_field_to_hide_in_group_by',
                }).then(function (result) {
                    for(var i=0;i<result.length;i++){
                        searchview.$buttons.find('option[data-name="' + result[i] + '"]').hide();
                    }
                    })
            }
            },
        });
});

Then add a xml file to consider your JS : template.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assets_backend_extension" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="Path_to_your_js_file"></script>
</xpath>
</template>
</data>
</odoo>
and finally, add your Xml file to your manifest and update your module.

Explanation :
Until now, i couldn't figure out how to not consider the fields before the construction of the
option elements
. So what i did, is just hide Them.
The RPC is for calling the python function that i already added to list all the fields i want to hide in Group By. for ex :
@api.model
def get_fields_to_ignore_in_search(self):
return ['field1', 'field2', 'field3']
1Commentaires
Avatar
Annuler
Avatar
Manish Kumar Bohra
-

Thanks it's working for me in group by but i have query related to can hide filter in group by using python like

you suggest in above link

https://www.odoo.com/fr_FR/forum/aide-1/question/hide-filter-name-from-add-custom-filter-drop-down-147813#answer-147820.

0
Avatar
EnayfuoS
Meilleure réponse

As an alternative to Boudmir's answer (Group By part), you can override the get_groupable_fields of web.Widget component defined in search_menu.js.

Then you have to create an xml file just like mentionned in Boudmir's answer to consider your new js file.

Avatar
Annuler