How can I modify the pivot view to do the following:
- Restrict the groupable fields in the rows and columns i.e. I want certain fields in the rows only and certain fields in the columns only
- Hide the None group in the table
Odoo v18 Community Edition
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
How can I modify the pivot view to do the following:
Odoo v18 Community Edition
Hi,
1- Restricting Groupable Fields in Rows/Columns
<record id="view_model_my_pivot" model="ir.ui.view">
<field name="name">my.model.pivot.restricted</field>
<field name="model">my.model</field>
<field name="arch" type="xml">
<pivot string="Custom Analysis" default_group_by="[['category']]" >
<field name="category" type="row"/>
<field name="user_id" type="col"/>
<field name="amount" type="measure"/>
<field name="count" type="measure"/>
</pivot>
</field>
</record>
- <field name="category" type="row"/> :- This field will be used for rows in the pivot table. It implies that the pivot table will group data based on the "category" field of the model.
- <field name="user_id" type="col"/> :- This field will be used for columns in the pivot table. It implies that the pivot table will organize data horizontally based on the "user_id" field of the model.
2. Removing Unwanted Options from ‘Group By’ & Hiding “None”
- To hide the “None” group in a pivot view in Odoo 18 Community Edition, you need to ensure that the fields used for grouping (rows or columns) never have null/False values in the dataset being visualized. Odoo shows "None" automatically when grouped fields are empty.
* Add a domain to exclude nulls:-
Edit you action as,
<record id="action_my_model_pivot" model="ir.actions.act_window">
<field name="name">My Pivot</field>
<field name="res_model">my.model</field>
<field name="view_mode">pivot</field>
<field name="domain">[('my_group_field', '!=', False)]</field>
</record>
Hope it helps
1. The code you've given sets the default row and col, but users can still change the fields to group by. This doesn't enforce the restriction of fields that I want.
2. The nature of my model and data is such that all records will have certain fields False.
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-seRelated Posts | Respostes | Vistes | Activitat | |
---|---|---|---|---|
|
1
de juny 25
|
649 | ||
|
1
de jul. 25
|
377 | ||
|
3
de jul. 25
|
725 | ||
|
1
de juny 25
|
479 | ||
|
1
de jul. 25
|
509 |