~openerp-community/openobject-doc/6.1

« back to all changes in this revision

Viewing changes to source/developer/7_23_RAD_tools/index.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
=========
 
2
RAD Tools 
 
3
=========
 
4
 
 
5
DIA
 
6
===
 
7
        
 
8
The uml_dia module helps to develop new modules after an UML description using the DIA tool (http://www.gnome.org/projects/dia).
 
9
 
 
10
It's not a typical module in the sense that you don't have to install it on the server as another module. The contents of the module are just a python script for dia (codegen_openerp.py), a test dia diagram and the module generated by the test.
 
11
 
 
12
The module is located in the extra_addons branch: https://code.launchpad.net/openobject-addons
 
13
 
 
14
To use the module you need to make **codegen_openerp.py** accesible from dia, usually in your **/usr/share/dia/python** directory and make sure that it gets loaded once. To do it, just open dia and open a **Python Console** from the **Dialog Menu**, and type there "import codegen_openerp". If everything goes alright you will have a new option in your "Export..." dialog named "PyDia Code Generation (OpenERP)" that will create a zip module from your UML diagram.
 
15
 
 
16
To install win Dia in windows, first install Python-2.2, then when you install Dia, you will have an option to install the python plug-in. After this, put the codegen_openerp.py file in C:\Program Files\Dia and you will have the export function in Dia.
 
17
 
 
18
If you find that the zip file is corrupt, use DiskInternals ZipRepair utility to repair the zip file before you'll be able to import it - make sure the zip file you import has the same name you saved as. 
 
19
 
 
20
Open Office Report Designer
 
21
===========================
 
22
Select Tiny Report > Server parameters or Open ERP Report > Server parameters in the top menu of OpenOffice.org Writer. You can then enter your connection parameters to the Open ERP server. You must select a database \ ``demo_min``\   in which you've already installed the module \ ``sale``\  . A message appears if you've made a successful connection.
 
23
 
 
24
.. index::
 
25
   single: Report; Modify
 
26
..
 
27
 
 
28
Modifying a report
 
29
-------------------
 
30
 
 
31
The report editor lets you:
 
32
 
 
33
* modify existing reports which will then replace the originals in your Open ERP database,
 
34
 
 
35
* create new reports for the selected object.
 
36
 
 
37
To modify an existing report, select  *Tiny Report > Modify Existing Report* . Choose the report \ ``Request for         Quotation``\   in the  *Modify Existing Report*  dialog box and then click  *Save to Temp Directory* .
 
38
 
 
39
 
 
40
.. image::  images/openoffice_quotation.png
 
41
   :align: center
 
42
 
 
43
*Modifying a document template*
 
44
 
 
45
OpenOffice.org then opens the report in edit mode for you. You can modify it using the standard word processing functions of OpenOffice.org Writer.
 
46
 
 
47
The document is modified in its English version. It will be translated as usual by Open ERP's translation system when you use it through the client interface, if you've personalized your own setup to translate to another language for you. So you only need to modify the template once, even if your system uses other languages – but you'll need to add translations as described earlier in this chapter if you add fields or change the content of the existing ones.
 
48
 
 
49
.. tip::   **Attention**  *Older reports*
 
50
 
 
51
The older reports haven't all been converted into the new form supported by Open ERP. The data expressions in the old format are shown within double brackets and not in OpenOffice.org fields.
 
52
 
 
53
You can transform an old report format to the new format from the OpenOffice.org menu Tiny Report > Convert Bracket–Fields.
 
54
 
 
55
From the Tiny toolbar in OpenOffice.org it's possible to:
 
56
 
 
57
* connect to the Open ERP server: by supplying the connection parameters.
 
58
 
 
59
* add a loop: select a related field amongst the available fields from the proposed object, for example \ ``Order lines``\  . When it's printed this loop will be run for each line of the order. The loop can be put into a table (the lines will then be repeated) or into an OpenOffice.org section.
 
60
 
 
61
* add a field: you can then go through the whole Open ERP database from the selected object and then a particular field.
 
62
 
 
63
* add an expression: enter an expression in the Python language to calculate values from any fields in the selected object.
 
64
 
 
65
.. tip::   **Technique**  *Python Expressions*
 
66
 
 
67
Using the Expression button you can enter expressions in the Python language. These expressions can use all of the object's fields for their calculations.
 
68
 
 
69
For example if you make a report on an order you can use the following expression:
 
70
 
 
71
.. code-block:: python
 
72
 
 
73
  '%.2f' % (amount_total * 0.9,)
 
74
 
 
75
.. *
 
76
 
 
77
In this example, amount_total is a field from the order object. The result will be 90% of the total of the order, formatted to two decimal places.
 
78
 
 
79
 *Tiny Report > Send to server*  *Technical Name*  *Report Name* \ ``Sale Order Mod``\   *Corporate Header*  *Send Report to Server*
 
80
 
 
81
You can check the result in Open ERP using the menu  *Sales Management > Sales Orders > All Orders* .
 
82
 
 
83
.. index::
 
84
   single: Report; New
 
85
..
 
86
 
 
87
Creating a new report
 
88
---------------------
 
89
 
 
90
 *Tiny Report > Open a new report* \ ``Sale Order``\   *Open New Report*  *Use Model in Report*
 
91
 
 
92
The general template is made up of loops (such as the list of selected orders) and fields from the object, which can also be looped. Format them to your requirements then save the template.
 
93
 
 
94
The existing report templates make up a rich source of examples. You can start by adding the loops and several fields to create a minimal template.
 
95
 
 
96
When the report has been created, send it to the server by clicking  *Tiny Report > Send to server* , which brings up the  *Send to server*  dialog box. Enter the  *Technical Name*  of \ ``sale.order``\  , to make it appear beside the other sales order reports. Rename the template as \ ``Sale Order New``\   in  *Report Name* , check the checkbox  *Corporate Header*  and finally click  *Send Report to Server* .
 
97
 
 
98
To send it to the server, you can specify if you prefer Open ERP to produce a PDF when the user prints the document, or if Open ERP should open the document for editing in OpenOffice.org Writer before printing. To do that choose \ ``PDF``\   or \ ``SXW``\   (a format of OpenOffice.org documents) in the field  *Select Report Type*
 
99
 
 
100
Open ERP objects can be created from PostgreSQL views. The technique is as follows :
 
101
 
 
102
   1. Declare your _columns dictionary. All fields must have the flag readonly=True.
 
103
   2. Specify the parameter _auto=False to the Open ERP object, so no table corresponding to the _columns dictionnary is created automatically.
 
104
   3. Add a method init(self, cr) that creates a PostgreSQL View matching the fields declared in _columns. 
 
105
 
 
106
Example The object report_crm_case_user follows this model.
 
107
 
 
108
.. code-block:: python
 
109
 
 
110
        report_crm_case_user(osv.osv):
 
111
             _name = "report.crm.case.user"
 
112
             _description = "Cases by user and section"
 
113
             _auto = False
 
114
             _columns = {
 
115
                'name': fields.date('Month', readonly=True),
 
116
                'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
 
117
                'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
 
118
                'amount_revenue': fields.float('Est.Revenue', readonly=True),
 
119
               'amount_costs': fields.float('Est.Cost', readonly=True),
 
120
                'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
 
121
                'nbr': fields.integer('# of Cases', readonly=True),
 
122
               'probability': fields.float('Avg. Probability', readonly=True),
 
123
                'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
 
124
                'delay_close': fields.integer('Delay to close', readonly=True),
 
125
            }
 
126
             _order = 'name desc, user_id, section_id'
 
127
         
 
128
            def init(self, cr):
 
129
                cr.execute("""
 
130
                     create or replace view report_crm_case_user as (
 
131
                         select
 
132
                             min(c.id) as id,
 
133
                             substring(c.create_date for 7)||'-01' as name,
 
134
                             c.state,
 
135
                             c.user_id,
 
136
                             c.section_id,
 
137
                             count(*) as nbr,
 
138
                             sum(planned_revenue) as amount_revenue,
 
139
                             sum(planned_cost) as amount_costs,
 
140
                             sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
 
141
                             avg(probability)::decimal(16,2) as probability,
 
142
                             to_char(avg(date_closed-c.create_date), 'DD"d" `HH24:MI:SS') as delay_close
 
143
                         from
 
144
                             crm_case c
 
145
                         group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
 
146
                )""")
 
147
        report_crm_case_user()
 
148
 
 
149