Skip to content

Commit a485530

Browse files
committed
[FIX] orm: adapt indentation of python examples
This commit fixes the current indentation of python blocks, as they're not valid.
1 parent 67289e1 commit a485530

File tree

1 file changed

+20
-13
lines changed
  • content/developer/reference/backend

1 file changed

+20
-13
lines changed

content/developer/reference/backend/orm.rst

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,18 +1227,20 @@ When using :attr:`~odoo.models.Model._inherit` but leaving out
12271227
:attr:`~odoo.models.Model._name`, the new model replaces the existing one,
12281228
essentially extending it in-place. This is useful to add new fields or methods
12291229
to existing models (created in other modules), or to customize or reconfigure
1230-
them (e.g. to change their default sort order)::
1230+
them (e.g. to change their default sort order)
1231+
1232+
.. code-block:: python
12311233
12321234
class Extension0(models.Model):
1233-
_name = 'extension.0'
1234-
_description = 'Extension zero'
1235+
_name = 'extension.0'
1236+
_description = 'Extension zero'
12351237
1236-
name = fields.Char(default="A")
1238+
name = fields.Char(default="A")
12371239
12381240
class Extension0(models.Model):
1239-
_inherit = 'extension.0'
1241+
_inherit = 'extension.0'
12401242
1241-
description = fields.Char(default="Extended")
1243+
description = fields.Char(default="Extended")
12421244
12431245
.. code-block:: python3
12441246
@@ -1249,11 +1251,12 @@ will yield::
12491251

12501252
{'name': "A", 'description': "Extended"}
12511253

1252-
.. warning:: if you use :attr:`~odoo.models.Model._inherit` with a list
1253-
but leaving out :attr:`~odoo.models.Model._name`, the class
1254-
name will be used to infer the model you're extending.
1255-
This is not the case when :attr:`~odoo.models.Model._inherit`
1256-
is a ``string``
1254+
.. warning:: When :attr:`~odoo.models.Model._inherit` is set using a string,
1255+
this will also set the value of :attr:`~odoo.models.Model._name`.
1256+
In all the other cases the :attr:`~odoo.models.Model._name` is set by
1257+
the attribute itself or by the class name (i.e: ``class MyModel(models.Model)`` will be
1258+
translated into ``_name = 'my.model'``, even if not explicitly set)
1259+
12571260

12581261

12591262
.. note::
@@ -1273,7 +1276,9 @@ model.
12731276

12741277
The main difference is in the meaning. When using Delegation, the model
12751278
**has one** instead of **is one**, turning the relationship in a composition
1276-
instead of inheritance::
1279+
instead of inheritance
1280+
1281+
.. code-block:: python
12771282
12781283
class Screen(models.Model):
12791284
_name = 'delegation.screen'
@@ -1341,8 +1346,10 @@ In that case, the attributes of the field are taken from the parent class
13411346
and overridden by the ones given in subclasses.
13421347

13431348
For instance, the second class below only adds a tooltip on the field
1344-
``state``::
1349+
``state``
13451350

1351+
.. code-block:: python
1352+
13461353
class FirstFoo(models.Model):
13471354
state = fields.Selection([...], required=True)
13481355

0 commit comments

Comments
 (0)