@@ -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,
12281228essentially extending it in-place. This is useful to add new fields or methods
12291229to 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
12741277The 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,7 +1346,9 @@ In that case, the attributes of the field are taken from the parent class
13411346and overridden by the ones given in subclasses.
13421347
13431348For instance, the second class below only adds a tooltip on the field
1344- ``state ``::
1349+ ``state ``
1350+
1351+ .. code-block :: python
13451352
13461353 class FirstFoo (models .Model ):
13471354 state = fields.Selection([... ], required = True )
0 commit comments