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

I want to create a graph view with only a bar graph so the pie and line graph must be hidden/removed at the same time I want the stacked button to be hidden/removed 

this is my graph view



this is my action window


this is my menu item



And this is how it looks like in my Module

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

By default, Odoo’s Graph View provides options to switch between Bar, Line, and Pie charts, along with a Stacked toggle.


To restrict the view to only Bar charts and hide the other options (Pie, Line, and Stacked), you can use specific attributes in the <graph> tag within your XML view definition.


xml -


<record id="your_graph_view_id" model="ir.ui.view">

    <field name="name">your.model.graph.view</field>

    <field name="model">your.model</field>

    <field name="arch" type="xml">

        <graph string="Your Graph" type="bar"

               disable_pie="1"

               disable_line="1"

               disable_stacked_bar="1">

            <field name="your_group_by_field" type="row"/>

            <field name="your_measure_field" type="measure"/>

        </graph>

    </field>

</record>


Explanation of Attributes-


type="bar": -Sets the default chart type to Bar.


disable_pie="1": Hides the Pie chart option from the toolbar.


disable_line="1": Hides the Line chart option.


disable_stacked_bar="1": Hides the Stacked toggle button.


Hope it helps

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

         

try this one


Ảnh đại diện
Huỷ bỏ

<graph string="Custom Bar Graph View" type="bar" mode="primary">

Tác giả

doesn't work it results in an error that says
View error context:
-no context-

<graph string="Custom Bar Graph View" type="bar" mode="primary">
<!-- Ensure that only the bar chart is visible -->
<field name="graph_type" invisible="1">bar</field>
<field name="stacked" invisible="1"/>
</graph>

Tác giả

still will not work besides the fact that the mode="primary" is the reason why it said no context
the second reason would be because if you code this in
<field name="graph_type" invisible="1">bar</field>
<field name="stacked" invisible="1"/>
it will say that it is not found in the model

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 24
14
0
thg 7 24
31
2
thg 7 25
869
0
thg 9 25
103
1
thg 3 25
1422