Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
15941 Lượt xem

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

Thanks. 

Ảnh đại diện
Huỷ bỏ
Tác giả

that was only the Filters' part ;)

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

Tác giả Câu trả lời hay nhất

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']
Ảnh đại diện
Huỷ bỏ

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.

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 20
2947
0
thg 1 20
3168
1
thg 12 19
4162
1
thg 5 24
3023
1
thg 3 22
13384