Graph views

A graph is a new mode of view for all views of type form. If, for example, a sale order line must be visible as list or as graph, define it like this in the action that open this sale order line. Do not set the view mode as “tree,form,graph” or “form,graph” - it must be “graph,tree” to show the graph first or “tree,graph” to show the list first. (This view mode is extra to your “form,tree” view and should have a seperate menu item):

  1. <field name="view_type">form</field>
  2. <field name="view_mode">tree,graph</field>

view_type:

  1. tree = (tree with shortcuts at the left), form = (switchaable view form/list)

view_mode:

  1. tree,graph : sequences of the views when switching

接下来,用户可以从一个视图转换到另一个视图。不像表单和列表视图一样,OpenERP不能自动按需创建graph视图,所以你必须自己定义graph视图:

  1. <record model="ir.ui.view" id="view_order_line_graph">
  2. <field name="name">sale.order.line.graph</field>
  3. <field name="model">sale.order.line</field>
  4. <field name="type">graph</field>
  5. <field name="arch" type="xml">
  6. <graph string="Sales Order Lines">
  7. <field name="product_id" group="True"/>
  8. <field name="price_unit" operator="*"/>
  9. </graph>
  10. </field>
  11. </record>

The graph view

graph类型的视图只是graph的字段列表。

Graph tag

graph的默认类型是圆形分格统计图表(pie chart),要将它转换成条形图(barchart),就需要将 转换成 ,你也可以改变方向。

:例如 :

  1. <graph string="Sales Order Lines" orientation="horizontal" type="bar">

Field tag

第一个字段是x轴,第二个是y轴,第三个是z轴,这个是可选择的三维图字段。你可以运用一些属性到每个field/axis。

  • group: if set to true, the client will group all item of the same value for this field. For each other field, it will apply an operator

  • operator: the operator to apply is another field is grouped. By default it’s ‘+’. Allowed values are:

    • +: addition

    • *: multiply

    • **: exponent

    • min: minimum of the list

    • max: maximum of the list

Defining real statistics on objects:
 

定义真正的对象数据统计:

  1. Define a statistic object wich is a postgresql view

  2. 在这个对象上创建一个tree view和graph view

You can get en example in all modules of the form: report_…. Example: report_crm.