Skip to content

Commit 0c9ef1f

Browse files
committed
[ADD] util/specific.py: add helper to rename model
while changing custom model name every time we have to add migration report, so introducing this to reduce the line of code [reference](7786de7) closes #65 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent a10d426 commit 0c9ef1f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/util/specific.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from .helpers import _validate_table
55
from .misc import _cached
6+
from .models import rename_model
67
from .modules import rename_module
78
from .pg import column_exists, rename_table
89
from .report import add_to_migration_reports
@@ -43,6 +44,17 @@ def dispatch_by_dbuuid(cr, version, callbacks):
4344
func(cr, version)
4445

4546

47+
def rename_custom_model(cr, model_name, new_model_name, custom_module=None, report_details=""):
48+
rename_model(cr, model_name, new_model_name, rename_table=True)
49+
module_details = " from module '{}'".format(custom_module) if custom_module else ""
50+
add_to_migration_reports(
51+
category="Custom models",
52+
message="The custom model '{model_name}'{module_details} was renamed to '{new_model_name}'. {report_details}".format(
53+
**locals()
54+
),
55+
)
56+
57+
4658
def rename_custom_module(cr, old_module_name, new_module_name, report_details=""):
4759
rename_module(cr, old_module_name, new_module_name)
4860

0 commit comments

Comments
 (0)