summaryrefslogtreecommitdiff
path: root/doc/reference
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-11-15 13:53:05 +0000
committerjem-odoo <jem@openerp.com>2019-03-05 08:41:23 +0000
commitd256350f34a49cc6900bce53852832d1fac4f5d2 (patch)
treeec287d04a3d8e6426fc6248dfa45bf240a05fee3 /doc/reference
parent64662cc2a9f4bbb0cc4a1182a6fe6966090bde8a (diff)
[IMP] guidelines: improve xml ids naming section
* rewording of XML naming section * remove the convention of suffixing inherited XML ids with `_inherit_my_module, as the information is in the complete XML id name (prefixed by module name). This will avoid too long XML ids. * extend convention for the name of groups, views, ... Task-1817988
Diffstat (limited to 'doc/reference')
-rw-r--r--doc/reference/guidelines.rst60
1 files changed, 34 insertions, 26 deletions
diff --git a/doc/reference/guidelines.rst b/doc/reference/guidelines.rst
index 91d7e3d1a72..5122383a28a 100644
--- a/doc/reference/guidelines.rst
+++ b/doc/reference/guidelines.rst
@@ -280,8 +280,8 @@ Odoo supports custom tags acting as syntactic sugar:
The 4 first tags are prefered over the *record* notation.
-Naming xml_id
--------------
+XML IDs and naming
+------------------
Security, View and Action
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -304,17 +304,33 @@ Use the following pattern :
for the 'model_name_group_user', 'public' for public user, 'company'
for multi-company rules, ...).
+Name should be identical to xml id with dots replacing underscores. Actions
+should have a real naming as it is used as display name.
+
.. code-block:: xml
- <!-- views and menus -->
+ <!-- views -->
<record id="model_name_view_form" model="ir.ui.view">
+ <field name="name">model.name.view.form</field>
...
</record>
<record id="model_name_view_kanban" model="ir.ui.view">
+ <field name="name">model.name.view.kanban</field>
...
</record>
+ <!-- actions -->
+ <record id="model_name_action" model="ir.act.window">
+ <field name="name">Model Main Action</field>
+ ...
+ </record>
+
+ <record id="model_name_action_child_list" model="ir.actions.act_window">
+ <field name="name">Model Access Childs</field>
+ </record>
+
+ <!-- menus and sub-menus -->
<menuitem
id="model_name_menu_root"
name="Main Menu"
@@ -328,15 +344,6 @@ Use the following pattern :
sequence="10"
/>
- <!-- actions -->
- <record id="model_name_action" model="ir.actions.act_window">
- ...
- </record>
-
- <record id="model_name_action_child_list" model="ir.actions.act_window">
- ...
- </record>
-
<!-- security -->
<record id="module_name_group_user" model="res.groups">
...
@@ -350,30 +357,31 @@ Use the following pattern :
...
</record>
+Inheriting XML
+~~~~~~~~~~~~~~
+Xml Ids of inheriting views should use the same ID as the original record.
+It helps finding all inheritance at a glance. As final Xml Ids are prefixed
+by the module that creates them there is no overlap.
-.. 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
-
-#. Extension mode: Use the same xml id than the original view you are extending, and suffix it by :samp:`{_inherit}` . For instance, the view :samp:`project.project_view_form` can be extended by :samp:`project_forecast.project_view_form_inherit`.
-#. Primary mode: Keep the original xml id.
-
+Naming should contain an ``.inherit.{details}`` suffix to ease understanding
+the override purpose when looking at its name.
.. code-block:: xml
- <record id="module2.model_view_form_inherit" model="ir.ui.view">
+ <record id="model_view_form" model="ir.ui.view">
+ <field name="name">model.view.form.inherit.module2</field>
<field name="inherit_id" ref="module1.model_view_form"/>
...
</record>
+New primary views do not require the inherit suffix as those are new records
+based upon the first one.
+
+.. code-block:: xml
+
<record id="module2.model_view_form" model="ir.ui.view">
+ <field name="name">model.view.form.module2</field>
<field name="inherit_id" ref="module1.model_view_form"/>
<field name="mode">primary</field>
...