Hi All,
How to hide Fields in Filters and Group by in kanban, list, pivot.. views ?
Thanks.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi All,
How to hide Fields in Filters and Group by in kanban, list, pivot.. views ?
Thanks.
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"?>and finally, add your Xml file to your manifest and update your module.
<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>
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']
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
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.
You already have answered it here : https://www.odoo.com/forum/help-1/question/hide-filter-name-from-add-custom-filter-drop-down-147813
that was only the Filters' part ;)
I prefered to join the answer for both cases ( Filters and Group By) in one post.