~openerp-community/openobject-doc/ksa-openobject-doc-6.0

« back to all changes in this revision

Viewing changes to i18n/ru/source/developer/4_14_dashboard/index.rst

  • Committer: Don Kirkby
  • Date: 2011-02-21 20:46:11 UTC
  • mfrom: (433.1.53 openobject-doc)
  • Revision ID: donkirkby+launpd@gmail.com-20110221204611-1ykt6dmg4k3gh5dh
[MERGE] revisions 477 to 486 from the 5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
.. i18n: Dashboard 
 
3
.. i18n: =========
 
4
..
 
5
 
 
6
Dashboard 
 
7
=========
 
8
 
 
9
.. i18n: OpenERP objects can be created from PostgreSQL views. The technique is as follows :
 
10
..
 
11
 
 
12
OpenERP objects can be created from PostgreSQL views. The technique is as follows :
 
13
 
 
14
.. i18n:    1. Declare your _columns dictionary. All fields must have the flag **readonly=True.**
 
15
.. i18n:    2. Specify the parameter **_auto=False** to the OpenERP object, so no table corresponding to the _columns dictionnary is created automatically.
 
16
.. i18n:    3. Add a method **init(self, cr)** that creates a *PostgreSQL* View matching the fields declared in _columns. 
 
17
..
 
18
 
 
19
   1. Declare your _columns dictionary. All fields must have the flag **readonly=True.**
 
20
   2. Specify the parameter **_auto=False** to the OpenERP object, so no table corresponding to the _columns dictionnary is created automatically.
 
21
   3. Add a method **init(self, cr)** that creates a *PostgreSQL* View matching the fields declared in _columns. 
 
22
 
 
23
.. i18n: **Example** The object report_crm_case_user follows this model.
 
24
..
 
25
 
 
26
**Example** The object report_crm_case_user follows this model.
 
27
 
 
28
.. i18n: .. code-block:: python 
 
29
.. i18n: 
 
30
.. i18n:      class report_crm_case_user(osv.osv):
 
31
.. i18n:        _name = "report.crm.case.user"
 
32
.. i18n:        _description = "Cases by user and section"
 
33
.. i18n:        _auto = False
 
34
.. i18n:         _columns = {
 
35
.. i18n:        'name': fields.date('Month', readonly=True),
 
36
.. i18n:        'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
 
37
.. i18n:        'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
 
38
.. i18n:        'amount_revenue': fields.float('Est.Revenue', readonly=True),
 
39
.. i18n:           'amount_costs': fields.float('Est.Cost', readonly=True),
 
40
.. i18n:        'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
 
41
.. i18n:        'nbr': fields.integer('# of Cases', readonly=True),
 
42
.. i18n:           'probability': fields.float('Avg. Probability', readonly=True),
 
43
.. i18n:        'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
 
44
.. i18n:        'delay_close': fields.integer('Delay to close', readonly=True),
 
45
.. i18n:        }
 
46
.. i18n:         _order = 'name desc, user_id, section_id'
 
47
.. i18n: 
 
48
.. i18n:        def init(self, cr):
 
49
.. i18n:        cr.execute("""
 
50
.. i18n:             create or replace view report_crm_case_user as (
 
51
.. i18n:                 select
 
52
.. i18n:                     min(c.id) as id,
 
53
.. i18n:                     substring(c.create_date for 7)||'-01' as name,
 
54
.. i18n:                     c.state,
 
55
.. i18n:                     c.user_id,
 
56
.. i18n:                     c.section_id,
 
57
.. i18n:                     count(*) as nbr,
 
58
.. i18n:                     sum(planned_revenue) as amount_revenue,
 
59
.. i18n:                     sum(planned_cost) as amount_costs,
 
60
.. i18n:                     sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
 
61
.. i18n:                     avg(probability)::decimal(16,2) as probability,
 
62
.. i18n:                     to_char(avg(date_closed-c.create_date), 'DD"d" `HH24:MI:SS') as delay_close
 
63
.. i18n:                 from
 
64
.. i18n:                     crm_case c
 
65
.. i18n:                 group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
 
66
.. i18n:        )""")
 
67
.. i18n:        report_crm_case_user()
 
68
..
 
69
 
 
70
.. code-block:: python 
 
71
 
 
72
     class report_crm_case_user(osv.osv):
 
73
        _name = "report.crm.case.user"
 
74
        _description = "Cases by user and section"
 
75
        _auto = False
 
76
         _columns = {
 
77
        'name': fields.date('Month', readonly=True),
 
78
        'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
 
79
        'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
 
80
        'amount_revenue': fields.float('Est.Revenue', readonly=True),
 
81
           'amount_costs': fields.float('Est.Cost', readonly=True),
 
82
        'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
 
83
        'nbr': fields.integer('# of Cases', readonly=True),
 
84
           'probability': fields.float('Avg. Probability', readonly=True),
 
85
        'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
 
86
        'delay_close': fields.integer('Delay to close', readonly=True),
 
87
        }
 
88
         _order = 'name desc, user_id, section_id'
 
89
 
 
90
        def init(self, cr):
 
91
        cr.execute("""
 
92
             create or replace view report_crm_case_user as (
 
93
                 select
 
94
                     min(c.id) as id,
 
95
                     substring(c.create_date for 7)||'-01' as name,
 
96
                     c.state,
 
97
                     c.user_id,
 
98
                     c.section_id,
 
99
                     count(*) as nbr,
 
100
                     sum(planned_revenue) as amount_revenue,
 
101
                     sum(planned_cost) as amount_costs,
 
102
                     sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
 
103
                     avg(probability)::decimal(16,2) as probability,
 
104
                     to_char(avg(date_closed-c.create_date), 'DD"d" `HH24:MI:SS') as delay_close
 
105
                 from
 
106
                     crm_case c
 
107
                 group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
 
108
        )""")
 
109
        report_crm_case_user()