diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-07-07 18:13:57 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-07-07 18:13:57 +0200 |
| commit | fe92deaa1d6654f4034a6091ded36c5549e08bbe (patch) | |
| tree | f6e6b04c292f07f942a2cdf46743fcc01e39b48e /doc/reference | |
| parent | 73cb55284b8a52e4cd6bb21e3a4758df3e50cc92 (diff) | |
| parent | 2de301df2477d1f5f5cb76a98b6c5605271ec3e5 (diff) | |
[MERGE] forward port of branch 8.0 up to 2de301d
Diffstat (limited to 'doc/reference')
| -rw-r--r-- | doc/reference/actions.rst | 2 | ||||
| -rw-r--r-- | doc/reference/async.rst | 4 | ||||
| -rw-r--r-- | doc/reference/cmdline.rst | 2 | ||||
| -rw-r--r-- | doc/reference/data.rst | 2 | ||||
| -rw-r--r-- | doc/reference/guidelines.rst | 106 | ||||
| -rw-r--r-- | doc/reference/http.rst | 2 | ||||
| -rw-r--r-- | doc/reference/javascript.rst | 2 | ||||
| -rw-r--r-- | doc/reference/module.rst | 10 | ||||
| -rw-r--r-- | doc/reference/orm.rst | 2 | ||||
| -rw-r--r-- | doc/reference/qweb.rst | 2 | ||||
| -rw-r--r-- | doc/reference/reports.rst | 2 | ||||
| -rw-r--r-- | doc/reference/security.rst | 8 | ||||
| -rw-r--r-- | doc/reference/testing.rst | 3 | ||||
| -rw-r--r-- | doc/reference/translations.rst | 11 | ||||
| -rw-r--r-- | doc/reference/views.rst | 17 | ||||
| -rw-r--r-- | doc/reference/workflows.rst | 2 |
16 files changed, 107 insertions, 70 deletions
diff --git a/doc/reference/actions.rst b/doc/reference/actions.rst index a0698be5516..cd356508097 100644 --- a/doc/reference/actions.rst +++ b/doc/reference/actions.rst @@ -1,3 +1,5 @@ +:banner: banners/actions.jpg + .. _reference/actions: ======= diff --git a/doc/reference/async.rst b/doc/reference/async.rst index c2aded839aa..d8d9c7db90f 100644 --- a/doc/reference/async.rst +++ b/doc/reference/async.rst @@ -7,8 +7,8 @@ Asynchronous Operations As a language (and runtime), javascript is fundamentally single-threaded. This means any blocking request or computation will -blocks the whole page (and, in older browsers, the software itself -even preventing users from switching to an other tab): a javascript +block the whole page (and, in older browsers, the software itself +even preventing users from switching to another tab): a javascript environment can be seen as an event-based runloop where application developers have no control over the runloop itself. diff --git a/doc/reference/cmdline.rst b/doc/reference/cmdline.rst index 434b0d9cd9d..626906951a2 100644 --- a/doc/reference/cmdline.rst +++ b/doc/reference/cmdline.rst @@ -1,3 +1,5 @@ +:banner: banners/cmdline.jpg + .. _reference/cmdline: =============================== diff --git a/doc/reference/data.rst b/doc/reference/data.rst index a53b1fa604b..cb17b7e866a 100644 --- a/doc/reference/data.rst +++ b/doc/reference/data.rst @@ -1,3 +1,5 @@ +:banner: banners/data_files.jpg + .. _reference/data: ========== diff --git a/doc/reference/guidelines.rst b/doc/reference/guidelines.rst index 542b23ae7ce..17e50fe89ae 100644 --- a/doc/reference/guidelines.rst +++ b/doc/reference/guidelines.rst @@ -1,20 +1,21 @@ +:banner: banners/odoo_guideline.jpg + .. highlight:: python -================= +=============== Odoo Guidelines -================= +=============== -This page introduce the new Odoo Coding Guidelines. This guidelines -aims to improve the quality of the code (better readability of source, -...) but also to improve Odoo Apps ! Indeed, a proper code will ease -the maintenance and debugging, lower the complexity and promote the -reliability. +This page introduce the new Odoo Coding Guidelines. These guidelines +aim to improve the quality of the code (better readability of source, +...) and Odoo Apps. Indeed, proper code ought ease maintenance, aid +debugging, lower complexity and promote reliability. Module structure ================ Directories ------------- +----------- A module is organised in a few directory : - *data/* : demo and data xml @@ -24,24 +25,24 @@ A module is organised in a few directory : - *static/* : contains the web assets, separated into *css/, js/, img/, lib/, ...* File naming ------------- +----------- For *views* declarations, split backend views from (frontend) templates in 2 differents files. -For *models*, split the business logic by sets of models, in each sets +For *models*, split the business logic by sets of models, in each set select a main model, this model gives its name to the set. If there is -only one set of module, its name is the same as the module name. For +only one model, its name is the same as the module name. For each set named <main_model> the following files may be created: -- models/<main_model>.py -- models/<inherited_main_model.py -- views/<main_model>_templates.xml -- views/<main_model>_views.xml +- :file:`models/{<main_model>}.py` +- :file:`models/{<inherited_main_model>}.py` +- :file:`views/{<main_model>}_templates.xml` +- :file:`views/{<main_model>}_views.xml` -For instance, *sale* module introduce ``sale_order`` and +For instance, *sale* module introduces ``sale_order`` and ``sale_order_line`` where ``sale_order`` is dominant. So the -<main_model> files will be named *models/sale_order.py* and -*views/sale_order_views.py*. +``<main_model>`` files will be named :file:`models/sale_order.py` and +:file:`views/sale_order_views.py`. For *data*, split them by purpose : demo or data. The filename will be @@ -54,7 +55,7 @@ static/js/im_chat.js, static/css/im_chat.css, static/xml/im_chat.xml, ...). Don't link data (image, libraries) outside Odoo : don't use an url to an image but copy it in our codebase instead. -The complete tree should looks like +The complete tree should look like .. code-block:: text @@ -96,7 +97,8 @@ The complete tree should looks like `-- <inherited_main_model>_views.xml -.. note:: Filename should only use only ``[a-z0-9_]`` +.. note:: File names should only contain ``[a-z0-9_]`` (lowercase + alphanumerics and ``_``) .. warning:: Use correct file permissions : folder 755 and file 644. @@ -141,16 +143,17 @@ Security, View and Action Use the following pattern : -* For a menu : *<model_name>_menu* -* For a view : *<model_name>_view_<view_type>*, where *view_type* is kanban, form, tree, search, ... -* For an action : the main action respects *<model_name>_action*. - Others are suffixed with *_<detail>*, where *detail* is a underscore - lowercase string explaining a little bit the action (Should not be - long). This is used only if multiple action are declared for the +* For a menu: :samp:`{<model_name>}_menu` +* For a view: :samp:`{<model_name>}_view_{<view_type>}`, where *view_type* is + ``kanban``, ``form``, ``tree``, ``search``, ... +* For an action: the main action respects :samp:`{<model_name>}_action`. + Others are suffixed with :samp:`_{<detail>}`, where *detail* is a + lowercase string briefly explaining the action. + This is used only if multiple actions are declared for the model. -* For a group : *<model_name>_group_<group_name>* where *group_name* - is the name of the group, genrally 'user', 'manager', ... -* For a rule : *<model_name>_rule_<concerned_group>* where +* For a group: :samp:`{<model_name>}_group_{<group_name>}` where *group_name* + is the name of the group, generally 'user', 'manager', ... +* For a rule: :samp:`{<model_name>}_rule_{<concerned_group>}` where *concerned_group* is the short name of the concerned group ('user' for the 'model_name_group_user', 'public' for public user, 'company' for multi-company rules, ...). @@ -194,12 +197,19 @@ Use the following pattern : -.. note:: View name use dot notation ``my.model.view_type`` or ``my.model.view_type.inherit`` instead of *"This is the form view of My Model"*. +.. note:: View names use dot notation ``my.model.view_type`` or + ``my.model.view_type.inherit`` instead of *"This is the form view of + My Model"*. Inherited XML ~~~~~~~~~~~~~ -The naming pattern of inherited view is *<base_view>_inherit_<current_module_name>*. A module can extend a view only one time, suffix the orginal name with *_inherit_<current_module_name>*, where *current_module_name* is the technical name of the module extending the view. + +The naming pattern of inherited view is +:samp:`{<base_view>}_inherit_{<current_module_name>}`. A module may only +extend a view once. Suffix the orginal name with +:samp:`_inherit_{<current_module_name>}` where *current_module_name* is the +technical name of the module extending the view. .. code-block:: xml @@ -215,7 +225,8 @@ Python PEP8 options ------------ -Using a linter can help to see syntax and semantic warning or error. Odoo Source Code try to respect Python standard, but some of them can be ignored. +Using a linter can help show syntax and semantic warnings or errors. Odoo +source code tries to respect Python standard, but some of them can be ignored. - E501: line too long - E301: expected 1 blank line, found 0 @@ -230,7 +241,7 @@ Imports ------- The imports are ordered as -#. Externals libs (One per line sorted and splitted in python stdlib) +#. External libraries (one per line sorted and split in python stdlib) #. Imports of ``openerp`` #. Imports from Odoo modules (rarely, and only if necessary) @@ -253,7 +264,7 @@ Inside these 3 groups, the imported lines are alphabetically sorted. Idioms -------- +------ - Prefer ``%`` over ``.format()``, prefer ``%(varname)`` instead of position (This is better for translation) - Try to avoid generators and decorators @@ -304,8 +315,8 @@ Symbols - In a Model attribute order should be #. Private attributes (``_name``, ``_description``, ``_inherit``, ...) #. Default method and ``_default_get`` - #. Fields declarations - #. Compute and search methods in the same order than field declaration + #. Field declarations + #. Compute and search methods in the same order as field declaration #. Constrains methods (``@api.constrains``) and onchange methods (``@api.onchange``) #. CRUD methods (ORM overrides) #. Action methods @@ -394,19 +405,18 @@ Prefix your commit with Then, in the message itself, specify the part of the code impacted by your changes (module name, lib, transversal object, ...) and a description of the changes. -- Always put meaning full commit message: commit message should be - self explanatory (long enough) including the name of the module that - has been changed and the reason behind that change. Do not use - single words like "bugfix" or "improvements". - -- Avoid commits which simultaneously impacts lots of modules. Try to - splits into different commits where impacted modules are different - (It will be helpful when we are going to revert that module - separately). +- Always include a meaningful commit message: it should be self explanatory + (long enough) including the name of the module that has been changed and the + reason behind the change. Do not use single words like "bugfix" or + "improvements". +- Avoid commits which simultaneously impact multiple modules. Try to + split into different commits where impacted modules are different + (It will be helpful if we need to revert a module separately). .. code-block:: text [FIX] website, website_mail: remove unused alert div, fixes look of input-group-btn + Bootstrap's CSS depends on the input-group-btn element being the first/last child of its parent. This was not the case because of the invisible @@ -415,10 +425,10 @@ Then, in the message itself, specify the part of the code impacted by your chang [IMP] fields: reduce memory footprint of list/set field attributes [REF] web: add module system to the web client + This commit introduces a new module system for the javascript code. Instead of using global ... -.. note:: The long description try to explain the *why* not the - *what*, the *what* can be seen in the diff - +.. note:: Use the long description to explain the *why* not the + *what*, the *what* can be seen in the diff diff --git a/doc/reference/http.rst b/doc/reference/http.rst index 9f83a303d92..e6946beda49 100644 --- a/doc/reference/http.rst +++ b/doc/reference/http.rst @@ -1,3 +1,5 @@ +:banner: banners/web_controllers.jpg + =============== Web Controllers =============== diff --git a/doc/reference/javascript.rst b/doc/reference/javascript.rst index 938c2237912..53e12f0a857 100644 --- a/doc/reference/javascript.rst +++ b/doc/reference/javascript.rst @@ -1,3 +1,5 @@ +:banner: banners/javascript.jpg + .. highlight:: javascript .. default-domain:: js diff --git a/doc/reference/module.rst b/doc/reference/module.rst index 5dd93ca2cf6..94edfb2eefc 100644 --- a/doc/reference/module.rst +++ b/doc/reference/module.rst @@ -1,3 +1,5 @@ +:banner: banners/module.jpg + ======= Modules ======= @@ -9,11 +11,11 @@ Modules Manifest ======== -The manifest file serves to both declare a python package as an Odoo module, -and to specify a number of module metadata. +The manifest file serves to declare a python package as an Odoo module +and to specify module metadata. It is a file called ``__openerp__.py`` and contains a single Python -dictionary, each dictionary key specifying a module metadatum. +dictionary, where each key specifies module metadatum. :: @@ -64,7 +66,7 @@ Available manifest fields are: define. When a module is installed, all of its dependencies are installed before - it. Likewise during modules loading. + it. Likewise dependencies are loaded before a module is loaded. ``data`` (``list(str)``) List of data files which must always be installed or updated with the module. A list of paths from the module root directory diff --git a/doc/reference/orm.rst b/doc/reference/orm.rst index 3f0da8b7b46..df216497688 100644 --- a/doc/reference/orm.rst +++ b/doc/reference/orm.rst @@ -1,3 +1,5 @@ +:banner: banners/orm_api.jpg + .. _reference/orm: ======= diff --git a/doc/reference/qweb.rst b/doc/reference/qweb.rst index 81b3966a0fd..7ebdf9ae04d 100644 --- a/doc/reference/qweb.rst +++ b/doc/reference/qweb.rst @@ -1,3 +1,5 @@ +:banner: banners/qweb.jpg + .. highlight:: xml .. _reference/qweb: diff --git a/doc/reference/reports.rst b/doc/reference/reports.rst index 3440c90d64b..ca3befe6596 100644 --- a/doc/reference/reports.rst +++ b/doc/reference/reports.rst @@ -1,3 +1,5 @@ +:banner: banners/reports.jpg + .. highlight:: xml ============ diff --git a/doc/reference/security.rst b/doc/reference/security.rst index 05ca9079fb7..98999bf415b 100644 --- a/doc/reference/security.rst +++ b/doc/reference/security.rst @@ -1,3 +1,5 @@ +:banner: banners/security.jpg + .. _reference/security: ================ @@ -22,12 +24,12 @@ Each access control has a model to which it grants permissions, the permissions it grants and optionally a group. Access controls are additive, for a given model a user has access all -permissions granted to any of its groups: if the user belongs to group *A* -which allows writing and group *B* which allows deleting, he can both write +permissions granted to any of its groups: if the user belongs to one group +which allows writing and another which allows deleting, they can both write and delete. If no group is specified, the access control applies to all users, otherwise -it only applies to the users belonging to the specific group. +it only applies to the members of the given group. Available permissions are creation (``perm_create``), searching and reading (``perm_read``), updating existing records (``perm_write``) and deleting diff --git a/doc/reference/testing.rst b/doc/reference/testing.rst index e1c78919f15..9523d732e0f 100644 --- a/doc/reference/testing.rst +++ b/doc/reference/testing.rst @@ -1,5 +1,8 @@ +:banner: banners/testing_modules.jpg + .. _reference/testing: + =============== Testing Modules =============== diff --git a/doc/reference/translations.rst b/doc/reference/translations.rst index 45616189c0d..9a2b6ae8b82 100644 --- a/doc/reference/translations.rst +++ b/doc/reference/translations.rst @@ -1,5 +1,8 @@ +:banner: banners/translate.jpg + .. _reference/translations: + =================== Translating Modules =================== @@ -13,7 +16,7 @@ your module's translatable terms and may find content to work with. .. todo:: needs technical features -Translations export is done via the administration interface by logging into +Translations export is performed via the administration interface by logging into the backend interface and opening :menuselection:`Settings --> Translations --> Import / Export --> Export Translations` @@ -65,7 +68,7 @@ Explicit exports ================ When it comes to more "imperative" situations in Python code or Javascript -code, Odoo is not able to automatically export translatable terms and they +code, Odoo cannot automatically export translatable terms so they must be marked explicitly for export. This is done by wrapping a literal string in a function call. @@ -81,11 +84,11 @@ In JavaScript, the wrapping function is generally :js:func:`openerp.web._t`: .. warning:: - Only literal strings can be marked for exports, not expressions and not + Only literal strings can be marked for exports, not expressions or variables. For situations where strings are formatted, this means the format string must be marked, not the formatted string:: - # bad, the extract may work but it will not correctly translate the text + # bad, the extract may work but it will not translate the text correctly _("Scheduled meeting with %s" % invitee.name) # good diff --git a/doc/reference/views.rst b/doc/reference/views.rst index 3cca4e4a5c6..b1cc0255520 100644 --- a/doc/reference/views.rst +++ b/doc/reference/views.rst @@ -1,5 +1,6 @@ -.. highlight:: xml +:banner: banners/views.jpg +.. highlight:: xml .. _reference/views: ===== @@ -12,7 +13,7 @@ Common Structure ================ View objects expose a number of fields, they are optional unless specified -otherwise) +otherwise. ``name`` (mandatory) only useful as a mnemonic/description of the view when looking for one in @@ -21,7 +22,7 @@ otherwise) the model linked to the view, if applicable (it doesn't for QWeb views) ``priority`` client programs can request views by ``id``, or by ``(model, type)``. For - the latter, all the views for the right type and model will be looked for, + the latter, all the views for the right type and model will be searched, and the one with the lowest ``priority`` number will be returned (it is the "default view"). @@ -146,7 +147,7 @@ root can have the following attributes: Defined as a mapping of colors to Python expressions. Values are of the form: :samp:`{color}:{expr}[;...]`. For each record, pairs are tested - in-order, the expression is evaluated for the record and if ``true`` the + in order, the expression is evaluated for the record and if ``true`` the corresponding color is applied to the row. If no color matches, uses the default text color (black). @@ -571,7 +572,7 @@ Button Box .......... Many relevant actions or links can be displayed in the form. For example, in -Opportunity form, the actions "Schedule a Call" and "Schedule a Meeting" take +Opportunity form, the actions "Schedule a Call" and "Schedule a Meeting" have an important place in the use of the CRM. Instead of placing them in the "More" menu, put them directly in the sheet as buttons (on the top right) to make them more visible and more easily accessible. @@ -579,8 +580,8 @@ make them more visible and more easily accessible. .. image:: forms/header3.png :class: img-responsive -Technically, the buttons are placed inside a <div> to group them as a block on -the right-hand side of the sheet. +Technically, the buttons are placed inside a ``<div>`` to group them as a +block on the right-hand side of the sheet. :: @@ -640,7 +641,7 @@ place inside the field, it *must not* be an example as they are often confused with filled data. One can also group fields together by rendering them "inline" inside an -explicit block element like `<div>``. This allows grouping semantically +explicit block element like ``<div>``. This allows grouping semantically related fields as if they were a single (composite) fields. The following example, taken from the *Leads* form, shows both placeholders and diff --git a/doc/reference/workflows.rst b/doc/reference/workflows.rst index a6890f05ab6..db57880436e 100644 --- a/doc/reference/workflows.rst +++ b/doc/reference/workflows.rst @@ -115,7 +115,7 @@ Activities ---------- While the transitions can be seen as the control structures of the workflows, -activities are the places where everything happens, from changing record +activities are where everything happens, from changing record states to sending email. Different kinds of activities exist: ``Dummy``, ``Function``, ``Subflow``, and |
