6
single: modules development
12
Here you will found informations about the organisation of the community in
13
OpenERP project. It include a description of the different tools used, the role
14
of the differents actors, and the different process for improvement management.
16
The whole organisation is managed through our launchpad projects: http://launchpad.net
17
Our projects on launchpad are currently organised like this:
20
+----------------------------+----------------------------------------------+--------------------------------------------+
21
| **Project name** | **URL** | **Description** |
22
+============================+==============================================+============================================+
24
| **openobject** | https://launchpad.net/openobject | the main super-project (group) where all |
25
| | | bugs, features and faq are managed |
27
+----------------------------+----------------------------------------------+--------------------------------------------+
29
| **openobject-bi** | https://launchpad.net/openobject-bin | business intelligence project |
31
+----------------------------+----------------------------------------------+--------------------------------------------+
33
| **openobject-server** | https://launchpad.net/openobject-server | the openobject server |
35
+----------------------------+----------------------------------------------+--------------------------------------------+
37
| **openobject-client** | https://launchpad.net/openobject-client | the openobject application client (gtk) |
39
+----------------------------+----------------------------------------------+--------------------------------------------+
41
| **openobject-client-web** | https://launchpad.net/openobject-client-web | the openobject web client (previously |
44
+----------------------------+----------------------------------------------+--------------------------------------------+
46
| **openobject-addons** | https://launchpad.net/openobject-addons | the project for all modules about |
49
+----------------------------+----------------------------------------------+--------------------------------------------+
51
| **openerp** | https://launchpad.net/openerp | packaging around openobject (a selection |
52
| | | of modules to build applications) |
54
+----------------------------+----------------------------------------------+--------------------------------------------+
59
Please refer to :ref:`how-to-get-the-latest-trunk-source-code-link` in the Bazaar section
61
If you don't know the Bazaar version control system, please read the :ref:`documentation on Bazaar <bazaar-link>`
63
.. _coding-guidelines-link:
68
Development Guidelines
69
""""""""""""""""""""""
74
Organisation of files in modules
75
################################
77
.. === Organisation of files in modules ===
79
The structure of a module should be like this::
82
/module_name/__init__.py
83
/module_name/__terp__.py
84
/module_name/module.py
85
/module_name/module_view.xml
86
/module_name/module_wizard.xml
87
/module_name/module_report.xml
88
/module_name/module_data.xml
89
/module_name/module_demo.xml
90
/module_name/module_security.xml
92
/module_name/wizard/__init__.py
93
/module_name/wizard/wizard_name.py
94
/module_name/wizard/wizard_name_view.xml
95
/module_name/wizard/wizard_name_workflow.xml
97
/module_name/report/__init__.py
98
/module_name/report/report_name.sxw
99
/module_name/report/report_name.rml
100
/module_name/report/report_name.py
102
Objects and fields namings
103
##########################
108
Each object defined in your module must have at least one security rule
109
defined on it to make it accessible.
111
.. describe:: Preventing SQL Injection:
114
Care must be taken not to introduce SQL injection vulnerabilities to SQL
115
queries. SQL Injection is a kind of vulnerability in which the user is able to
116
introduce undesirable clauses to a SQL query (such as circumventing filters or
117
executing **UPDATE** or **DELETE** commands) due to incorrect quoting in
120
In order to prevent SQL injection you need to be cautious when constructing SQL
121
query strings. Good advices are to use %d and %f when only numbers are to be
122
substituted and always use psycopg formatting parameters. For example the
123
following expression is incorrect:
125
.. code-block:: python
127
cr.execute( "SELECT * FROM table_name WHERE name='%s'" % client_supplied_string )
133
.. code-block:: python
135
cr.execute( "SELECT * FROM table_name WHERE name=%s", client_supplied_string )
139
should be used instead.
147
Follow Python PEP 8: http://www.python.org/dev/peps/pep-0008/
155
* use the Helvetica font everywhere
156
* margins (in millimeters):
160
- left: between 12 and 13 to allow punching holes without punching in the text area
161
- right: between 12 and 13
163
.. note:: the line separator between the header and the body can overlap slightly in the left and right margins: up to 9 millimeters on the left and up to 12 millimeters on the right
167
* for Titles use the font *Heveltica-Bold* with the size *14.5*
169
* put the context on each report: example, for the report account_balance: the context is the fiscal year and periods
171
* for the name of cells: use Capital Letter if the name contains more than one word (ex: Date Ordered)
172
* content and name of cells should have the same indentation
174
* for report, we can define two kinds of arrays:
176
- array with general information, like reference, date..., use:
178
+ *Bold-Helvetica* and size=8 for cells name
179
+ *Helvetica* size="8" for content
180
- array with detailed information, use:
182
+ *Helvetica-Bold* size *9* for cells names
183
+ *Helvetica* size *8* for content
185
.. describe:: Headers and footers for internal reports:
187
* Internal report = all accounting reports and other that have only internal use (not sent to customers)
188
* height of headers should be shorter
189
* take off corporate header and footer for internal report (Use a simplified header for internal reports: Company's name, report title, printing date and page number)
193
- company's name: in the middle of each page
194
- report's name: is printed centered after the header
195
- printing date: not in the middle of the report, but on the left in the header
196
- page number: on each page, is printed on the right. This page number should contain the current page number and the total of pages. Ex: page 3/15
199
- to avoid wasting paper, we have taken off the footer
201
.. describe:: table line separator:
203
* it's prettier if each line in the table have a light grey line as separator
204
* use a grey column separator only for array containing general information
206
.. describe:: table breaking
208
* a table header should at least have two data rows (no table header alone at the bottom of the page)
209
* when a big table is broken, the table header is repeated on every page
211
.. describe:: how to differentiate parents and children ?
213
* When you have more than one level, use these styles:
215
- for the levels 1 and 2:fontSize="8.0" fontName="Helvetica-Bold"
216
- from the third level, use:fontName="Helvetica" fontSize="8.0" and increase the indentation with 13 (pixels) for each level
217
- underline sums when the element is a parent
225
The name of the module are all lowercase, each word separated by underscrores.
226
Start always by the most relevant words, which are preferably names of others
227
modules on which it depends.
231
* account_invoice_layout
236
Each module must contains at least:
247
Each module must contains:
249
* A list of dependencies amongst others modules: ['account','sale']
251
- Provide only highest requirement level, not need to set ['account','base','product','sale']
252
* A version requirement string where base is the Open ERP version as a Python expression
254
- account>=1.0 && base=4.4
259
Each module must contains dema data for every object defined in the module.
261
If you implemented workflows in the module, create demo data that passes
262
most branches of your workflow. You can use the module recorder to help you
263
build such demo data.
265
User Interface Guidelines
266
"""""""""""""""""""""""""
274
Here is a good example:
278
- Customer Invoices (list)
280
+ Draft Customer Invoices (list)
281
+ Open Customer Invoices (list)
282
+ New Customer Invoice (form)
287
Add a *New ...* menu only if the user requires it, otherwise, open all
288
menus as lists. The *New ...* menu open as a form instead of a list. For example,
289
don't put *New ...* in a menu in the configuration part.
291
If you use folders that are clickable, their child must be of the
292
same object type. (we suppose that inheritancies are the same objects)
296
* *Customer Invoice*, should be *Customer Invoices*
299
If you want to create menu that filters on the user (*All* and *My*) put them at the same level:
310
Avoid Abbreviations in menus if possible. Example:
312
* BoM Lines -> Bill of Materials Lines
317
The dashboard menu must be under the report section of each main menu
319
* Good: Sales Management / Reporting / Dashboards / Sales Manager
320
* Bad: Dashboard / Sales / Sales Manager
322
If you want to manage the *This Month/ALL months* menu, put them at the latest level:
324
* Reporting/Timesheet by User/All Month
325
* Reporting/Timesheet by User/This Month
330
* The icon of the menu, must be set according to the end action of the wizard, example:
332
- wizard that prints a report, should use a report icon and not a wizard
333
- wizard that opens a list at the end, should use a list icon and not a wizard
338
The configuration menu must be at the top of the list, use a sequence=0
340
The *Reporting* menu is at the bottom of the list, use a sequence=50.
345
* Edit Categories -> Categories
346
* List of Categories -> Categories
354
* The state field, if any, must be at the bottom left corner of the view
355
* Buttons to make the state change at the right of this state field
360
Search criterions: search available on all columns of the list view
365
.. todo:: write 'Action Names' section
376
The default language for every development must be U.S. english.
378
For menus and fields, use uppercase for all first letters, excluding conjections:
382
Field Naming Conventions
383
^^^^^^^^^^^^^^^^^^^^^^^^
385
* Avoid generic terms in fields and use if possible explicit terms, some example:
387
- Name -> Sale Order Name
388
- Parent -> Bill of Material Parent
389
- Rate -> Currency Rate Conversion
390
- Amount -> Quantity Sold
392
Here are some rules to respect:
394
* many2one fields should respect this regex: '.*_id'
395
* one2many fields should respect this regex: '.*_ids'
396
* one2many relation table should respect this regex: '.*_rel'
397
* many2many fields should respect this regex: '.*_ids'
398
* use underscore to separate words
399
* avoid using uppercases
400
* if a field should be composed of several words, start by the most important words
402
* This is good: sale_price, partner_address_id
403
* This is bad: is_sellable
405
Object Naming Conventions
406
^^^^^^^^^^^^^^^^^^^^^^^^^
408
* All objects must start by the name of the module they are defined in.
409
* If an object is composed of several words, use points to separate words
417
* All Tree of resources are called *XXX's Structure*, unless a dedicated term exist for the concept
419
- Good: Location' Structure, Chart of Accounts, Categories' Structure
420
- Bad: Tree of Category, Tree of Bill of Materials
425
.. todo:: write 'Module Recorder' section
430
.. todo:: write 'Review quality' section