Skip to content

Commit 937bba3

Browse files
committed
[IMP] *: Using class name corresponding to odoo models
If the class does not have the correct name, it is possible to force the model name using `_name`. In order to minimize changes for migration scripts, the solution of forcing the `_name` is made instead of correcting the class names. Related PRs: odoo/odoo#178200 odoo/enterprise#69762 odoo/documentation#11115 odoo/upgrade#6577 closes #143 Related: odoo/design-themes#988 Signed-off-by: Xavier Morel (xmo) <[email protected]>
1 parent 715d65a commit 937bba3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/base/0.0.0/pre-models-ir_model_relation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def migrate(cr, version):
1515

1616

1717
class ModelRelation(models.Model):
18-
_inherit = "ir.model.relation"
18+
_name = "ir.model.relation"
19+
_inherit = ["ir.model.relation"]
1920
_module = "base"
2021

2122
@api.model

src/mail/0.0.0/pre-report-migration.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ def model_cr(f):
99
return f
1010

1111

12-
from odoo.addons.mail.models.mail_message import Message # noqa
12+
try:
13+
from odoo.addons.mail.models.mail_message import Message # noqa
14+
except ImportError:
15+
from odoo.addons.mail.models.mail_message import MailMessage
1316

1417
from odoo.addons.base.maintenance.migrations import util
1518

@@ -19,7 +22,7 @@ def migrate(cr, version):
1922

2023

2124
class MailMessage(models.Model):
22-
_inherit = "mail.message"
25+
_inherit = ["mail.message"]
2326
_module = "mail"
2427

2528
@model_cr

0 commit comments

Comments
 (0)