Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
2a89adef
Commit
2a89adef
authored
5 years ago
by
Christophe Simonis
Browse files
Options
Downloads
Plain Diff
[MERGE] forward port branch 10.0 up to
7b16abba
parents
61a51a86
7b16abba
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
odoo/modules/migration.py
+15
-3
15 additions, 3 deletions
odoo/modules/migration.py
with
15 additions
and
3 deletions
odoo/modules/migration.py
+
15
−
3
View file @
2a89adef
...
...
@@ -28,6 +28,8 @@ class MigrationManager(object):
Python file names must start by `pre-` or `post-` and will be executed, respectively,
before and after the module initialisation. `end-` scripts are run after all modules have
been updated.
A special folder named `0.0.0` can contain scripts that will be run on any version change.
In `pre` stage, `0.0.0` scripts are run first, while in `post` and `end`, they are run last.
Example:
<moduledir>
`-- migrations
...
...
@@ -40,6 +42,8 @@ class MigrationManager(object):
|-- 9.0.1.1 # processed only on a 9.0 server
| |-- pre-delete_table_z.py
| `-- post-clean-data.py
|-- 0.0.0
| `-- end-invariants.py # processed on all version update
`-- foo.py # not processed
"""
...
...
@@ -86,7 +90,7 @@ class MigrationManager(object):
return
version
# the version number already containt the server version
return
"
%s.%s
"
%
(
release
.
major_version
,
version
)
def
_get_migration_versions
(
pkg
):
def
_get_migration_versions
(
pkg
,
stage
):
versions
=
list
(
set
(
ver
for
lv
in
self
.
migrations
[
pkg
.
name
].
values
()
...
...
@@ -94,6 +98,13 @@ class MigrationManager(object):
if
lf
))
versions
.
sort
(
key
=
lambda
k
:
parse_version
(
convert_version
(
k
)))
if
"
0.0.0
"
in
versions
:
# reorder versions
versions
.
remove
(
"
0.0.0
"
)
if
stage
==
"
pre
"
:
versions
.
insert
(
0
,
"
0.0.0
"
)
else
:
versions
.
append
(
"
0.0.0
"
)
return
versions
def
_get_migration_files
(
pkg
,
version
,
stage
):
...
...
@@ -120,10 +131,11 @@ class MigrationManager(object):
parsed_installed_version
=
parse_version
(
installed_version
)
current_version
=
parse_version
(
convert_version
(
pkg
.
data
[
'
version
'
]))
versions
=
_get_migration_versions
(
pkg
)
versions
=
_get_migration_versions
(
pkg
,
stage
)
for
version
in
versions
:
if
parsed_installed_version
<
parse_version
(
convert_version
(
version
))
<=
current_version
:
if
((
version
==
"
0.0.0
"
and
parsed_installed_version
<
current_version
)
or
parsed_installed_version
<
parse_version
(
convert_version
(
version
))
<=
current_version
):
strfmt
=
{
'
addon
'
:
pkg
.
name
,
'
stage
'
:
stage
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment