From d256350f34a49cc6900bce53852832d1fac4f5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 15 Nov 2018 13:53:05 +0000 Subject: [PATCH] [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 --- doc/reference/guidelines.rst | 60 ++++++++++++++++++++---------------- 1 file 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 - + + model.name.view.form ... + model.name.view.kanban ... + + + Model Main Action + ... + + + + Model Access Childs + + + - - - ... - - - - ... - - ... @@ -350,30 +357,31 @@ Use the following pattern : ... +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 - + + model.view.form.inherit.module2 ... +New primary views do not require the inherit suffix as those are new records +based upon the first one. + +.. code-block:: xml + + model.view.form.module2 primary ...