[IMP] *: Using class name corresponding to odoo models

closes odoo/documentation#11115

Related: odoo/odoo#178200
Related: odoo/enterprise#69762
Related: odoo/upgrade#6577
Related: odoo/design-themes#988
Related: odoo/upgrade-util#143
Signed-off-by: Christophe Matthieu (chm) <chm@odoo.com>
This commit is contained in:
Gorash 2024-09-27 12:21:54 +02:00
parent 9368181d04
commit f1a607a9c7
8 changed files with 22 additions and 19 deletions

View File

@ -122,7 +122,7 @@ of global variables.
from odoo import models from odoo import models
class IrHttp(models.AbstractModel): class IrHttp(models.AbstractModel):
_inherit = 'ir.http' _inherit = ['ir.http']
@classmethod @classmethod
def _get_translation_frontend_modules_name(cls): def _get_translation_frontend_modules_name(cls):

View File

@ -1123,7 +1123,7 @@ fields, methods and meta-information (defaults & al) from its base.
class Inheritance1(models.Model): class Inheritance1(models.Model):
_name = 'inheritance.1' _name = 'inheritance.1'
_inherit = 'inheritance.0' _inherit = ['inheritance.0']
_description = 'Inheritance One' _description = 'Inheritance One'
def call(self): def call(self):
@ -1161,8 +1161,8 @@ them (e.g. to change their default sort order)::
name = fields.Char(default="A") name = fields.Char(default="A")
class Extension1(models.Model): class Extension0(models.Model):
_inherit = 'extension.0' _inherit = ['extension.0']
description = fields.Char(default="Extended") description = fields.Char(default="Extended")
@ -1263,12 +1263,16 @@ and overridden by the ones given in subclasses.
For instance, the second class below only adds a tooltip on the field For instance, the second class below only adds a tooltip on the field
``state``:: ``state``::
class First(models.Model): class FirstFoo(models.Model):
_name = 'foo'
state = fields.Selection([...], required=True) state = fields.Selection([...], required=True)
class Second(models.Model): class FirstFoo(models.Model):
_inherit = 'foo' _inherit = ['first.foo']
state = fields.Selection(help="Blah blah blah")
class WrongFirstFooClassName(models.Model):
_name = 'first.foo' # force the model name
_inherit = ['first.foo']
state = fields.Selection(help="Blah blah blah") state = fields.Selection(help="Blah blah blah")
.. _reference/exceptions: .. _reference/exceptions:

View File

@ -473,7 +473,7 @@ returned dictionary.
from odoo.http import request from odoo.http import request
class IrHttp(models.AbstractModel): class IrHttp(models.AbstractModel):
_inherit = 'ir.http' _inherit = ['ir.http']
def session_info(self): def session_info(self):
result = super(IrHttp, self).session_info() result = super(IrHttp, self).session_info()

View File

@ -3251,7 +3251,7 @@ Model Commons
------------- -------------
.. currentmodule:: odoo.addons.base.models.ir_ui_view .. currentmodule:: odoo.addons.base.models.ir_ui_view
.. autoattribute:: Model._date_name .. autoattribute:: Base._date_name
:noindex: :noindex:
.. _reference/view_architectures/activity: .. _reference/view_architectures/activity:

View File

@ -69,7 +69,7 @@ Fields
View records expose a number of fields. View records expose a number of fields.
.. autoclass:: odoo.addons.base.models.ir_ui_view.View() .. autoclass:: odoo.addons.base.models.ir_ui_view.IrUiView()
.. attribute:: name .. attribute:: name
@ -363,8 +363,8 @@ specifies how the matched node should be modified.
Model commons Model commons
============= =============
.. autoclass:: odoo.addons.base.models.ir_ui_view.View() .. autoclass:: odoo.addons.base.models.ir_ui_view.Base()
:noindex: :noindex:
.. automethod:: Model.get_views .. automethod:: Base.get_views
.. automethod:: Model.get_view .. automethod:: Base.get_view

View File

@ -134,7 +134,7 @@ existing model, which means we will use the first mechanism. For example::
from odoo import fields, models from odoo import fields, models
class InheritedModel(models.Model): class InheritedModel(models.Model):
_inherit = "inherited.model" _inherit = ["inherited.model"]
new_field = fields.Char(string="New Field") new_field = fields.Char(string="New Field")

View File

@ -67,7 +67,7 @@ module for the ``estate.property`` model. For now, the overridden action will si
from odoo import models from odoo import models
class InheritedModel(models.Model): class InheritedModel(models.Model):
_inherit = "inherited.model" _inherit = ["inherited.model"]
def inherited_action(self): def inherited_action(self):
return super().inherited_action() return super().inherited_action()

View File

@ -801,9 +801,8 @@ scheduling changes or discussions between teachers and assistants:
.. code-block:: python .. code-block:: python
:caption: ``academy/models.py`` :caption: ``academy/models.py``
class Courses(models.Model): class AcademyCourses(models.Model):
_name = 'academy.courses' _inherit = ['mail.thread']
_inherit = 'mail.thread'
name = fields.Char() name = fields.Char()
teacher_id = fields.Many2one('academy.teachers', string="Teacher") teacher_id = fields.Many2one('academy.teachers', string="Teacher")