~openerp-community/openobject-doc/6.1

« back to all changes in this revision

Viewing changes to source/developer/2_6_views_events/views/graph_view.rst

  • Committer: TruongSinh Tran
  • Date: 2009-07-19 19:02:35 UTC
  • Revision ID: truongsinh@vipescoserver-20090719190235-fu3bxcrbpvwuk5h7
[FIX] build_i18n.py .. raw:: html

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Graph views
 
2
--------------
 
3
 
 
4
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):
 
5
 
 
6
.. code-block:: xml
 
7
 
 
8
         <field name="view_type">form</field>
 
9
         <field name="view_mode">tree,graph</field>
 
10
 
 
11
Then, the user will be able to switch from one view to the other. Unlike forms and trees, Tiny ERP is not able to automatically create a view on demand for the graph type. So, you must define a view for this graph:
 
12
 
 
13
 
 
14
.. code-block:: xml
 
15
 
 
16
        <record model="ir.ui.view" id="view_order_line_graph">
 
17
           <field name="name">sale.order.line.graph</field>
 
18
           <field name="model">sale.order.line</field>
 
19
           <field name="type">graph</field>
 
20
           <field name="arch" type="xml">
 
21
                 <graph string="Sales Order Lines">
 
22
                      <field name="product_id" group="True"/>
 
23
                      <field name="price_unit" operator="*"/>
 
24
                </graph>
 
25
            </field>
 
26
        </record>
 
27
 
 
28
 
 
29
The graph view
 
30
 
 
31
A view of type graph is just a list of fields for the graph.
 
32
 
 
33
Graph tag
 
34
++++++++++
 
35
 
 
36
The default type of the graph is a pie chart - to change it to a barchart change **<graph string="Sales Order Lines">** to **<graph string="Sales Order Lines" type="bar">** You also may change the orientation.
 
37
 
 
38
:Example : 
 
39
 
 
40
.. code-block:: xml
 
41
 
 
42
        <graph string="Sales Order Lines" orientation="horizontal" type="bar">
 
43
 
 
44
Field tag
 
45
+++++++++
 
46
 
 
47
The first field is the X axis. The second one is the Y axis and the optionnal third one is the Z axis for 3 dimensional graphs. You can apply a few attributes to each field/axis:
 
48
 
 
49
    * **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
 
50
    * **operator**: the operator to apply is another field is grouped. By default it's '+'. Allowed values are:
 
51
          + +: addition
 
52
          + \*: multiply
 
53
          + \**: exponent
 
54
          + min: minimum of the list
 
55
          + max: maximum of the list 
 
56
 
 
57
:Defining real statistics on objects:
 
58
 
 
59
The easiest method to compute real statistics on objects is:
 
60
 
 
61
   1. Define a statistic object wich is a postgresql view
 
62
   2. Create a tree view and a graph view on this object 
 
63
 
 
64
You can get en example in all modules of the form: report\_.... Example: report_crm. 
 
65