Skip to content

Commit 5933c9d

Browse files
committed
fix(task): rename generate-module to create-module and add generate-module-migration functionality
1 parent a5a5b9d commit 5933c9d

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file. The format
2020
- Added `OpenUpgrade` as submodule.
2121
- Added `activate-venv` as default call for all commands.
2222
- New command `aggregate-git-repos`.
23+
- Template migration scripts with `generate-module-migration`
2324

2425
### Changed
2526

@@ -33,8 +34,9 @@ All notable changes to this project will be documented in this file. The format
3334
- Simplified the install command.
3435
- Replace `generate-module-docs` with `generate-oca-module-docs`.
3536
- Renamed `upgrade-odoo` to `run-enterprise-upgrade`.
36-
- Renamed `test-module-repo` to `test-modules`
37+
- Renamed `test-module-repo` to `test-modules`.
3738
- Refactored `test-modules` function.
39+
- Renamed `generate-module` to `create-module`.
3840

3941
## 2025-09-12
4042

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Open browser to [http://localhost:8069](http://localhost:8069) and login with `a
108108
Create a new module.
109109

110110
```bash
111-
task generate-module addons/project/project_sprint
111+
task create-module addons/project/project_sprint
112112
```
113113

114114
Add a new model.

task

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ help-table() {
115115
printf "$column" 'import-csv' '[db][path]' 'Import data from csv. Filename must match PostgreSQL table name.'
116116
printf "$column" 'import-website-data' '[env]' 'Import website data to Odoo database.'
117117
# Generate
118+
printf "$column" 'create-module' '[path]' 'Create new Odoo module from template.'
118119
printf "$column" 'generate-module-docs' '[path]' 'Generate readme file for module with OCA tools.'
119120
printf "$column" 'generate-module-model' '[path][model]' 'Generate model in module folder.'
120121
printf "$column" 'generate-module-inherit' '[path][model]' 'Generate inherited model in module folder.'
121122
printf "$column" 'generate-module-views' '[path][model]' 'Generate model views in module folder.'
122123
printf "$column" 'generate-module-security' '[path][model]' 'Generate model access file.'
124+
printf "$column" 'generate-module-migration' '[path]' 'Generate .'
123125
printf "$column" 'generate-module-snippet' '[path][model][ref]' 'Generate snippet for referefenced view.'
124126
printf "$column" 'generate-module-wizard' '[path][model]' 'Generate wizard for a model in module folder.'
125-
printf "$column" 'generate-module' '[path]' 'Create new Odoo module from template.'
126127
printf "$column" 'generate-module-repo' '[path]' 'Initialize Odoo module repo from template.'
127128
# Module
128129
printf "$column" 'lint-module' '[path]' 'Run pylint odoo for module.'
@@ -2056,7 +2057,7 @@ remove-module() {
20562057
odoo shell --database "$database" --config "$ODOO_RC" --addons-path="$ADDONS_PATH" --no-http
20572058
}
20582059

2059-
generate-module() {
2060+
create-module() {
20602061
if [[ -z "$1" ]]; then
20612062
echo '$1 is empty.'
20622063
exit
@@ -2102,20 +2103,19 @@ generate-module-docs() {
21022103
oca-gen-addon-readme --repo-name=$repo_name --branch=$ODOO_VERSION --org-name=$ORG_NAME --addon-dir=$module_path
21032104
}
21042105

2105-
template-module-readme() {
2106+
generate-module-migration() {
21062107
if [[ -z "$1" ]]; then
21072108
echo '$1 is empty.'
21082109
exit
21092110
fi
21102111
local module_path="$1"
2111-
local manifest_path="$module_path/__manifest__.py"
2112+
local module_version=$(get-module-version $module_path)
21122113

2113-
echo "Update $module_path/README.rst"
2114-
export MODULE_TITLE=$(python3 -c "import ast; d=ast.literal_eval(open('$manifest_path').read()); print(d.get('name', ''))")
2115-
export MODULE_UNDERLINE=$(python3 -c "import ast; d=ast.literal_eval(open('$manifest_path').read()); print('=' * len(d.get('name', '')))")
2116-
export MODULE_SUMMARY=$(python3 -c "import ast; d=ast.literal_eval(open('$manifest_path').read()); print(d.get('summary', '').replace('\n', ' ').strip())")
2117-
export MODULE_WIKI_PATH=$(basename "$module_path" | sed 's/_/-/g')
2118-
envsubst < templates/README.rst > "$module_path/README.rst"
2114+
echo "Create migrations folder for version $module_version."
2115+
mkdir -p "$module_path/migrations/$module_version"
2116+
2117+
echo "Copy pre-migrate template."
2118+
cp "templates/migrations/pre-migrate.py" "$module_path/migrations/$module_version"
21192119
}
21202120

21212121
generate-module-security() {

0 commit comments

Comments
 (0)