@@ -899,23 +899,79 @@ function ci_ensure_addons_have_changelog {
899
899
return $res ;
900
900
}
901
901
902
+ function ci_auto_migrate_modules {
903
+ local usage="
904
+ Try to automatically migrate modules to current odoo version.
905
+ It is not full migration, but just some predefined actions, that
906
+ could simplify migrations. The changes made by this command does not
907
+ change or update logic. Currently it is only set of find-and-replace rules
908
+ applied to module.
909
+
910
+ Usage:
911
+
912
+ $SCRIPT_NAME ci auto-migrate-modules [options] [args]
913
+
914
+ Options:
915
+ --help - print this help message
916
+
917
+ Args:
918
+ Same arguments as passed to odoo-helper addons list
919
+
920
+ Example:
921
+
922
+ # Command below will try to migrate all installable modules in
923
+ # current directory
924
+ $SCRIPT_NAME ci auto-migrate-modules --installable .
925
+ " ;
926
+ # Parse options
927
+ if [[ $# -lt 1 ]]; then
928
+ echo " $usage " ;
929
+ return 0;
930
+ fi
931
+ while [[ $# -gt 0 ]]
932
+ do
933
+ local key=" $1 " ;
934
+ case $key in
935
+ -h|--help|help)
936
+ echo " $usage " ;
937
+ return 0;
938
+ ;;
939
+ * )
940
+ break ;
941
+ ;;
942
+ esac
943
+ shift
944
+ done
945
+
946
+ local addons_to_migrate
947
+ mapfile -t addons_to_migrate < <( addons_list_in_directory --by-path " $@ " ) ;
948
+ for addon_path in " ${addons_to_migrate[@]} " ; do
949
+ local addon_name;
950
+ addon_name=$( addons_get_addon_name " $addon_path " ) ;
951
+ echoe -e " ${BLUEC} Migrating addon ${YELLOWC}${addon_name}${BLUEC} ...${NC} " ;
952
+ exec_py " ${ODOO_HELPER_LIB} /pylib/ci_fw_postfixes.py" --version=" $ODOO_VERSION " --path=" $addon_path " ;
953
+ echoe -e " ${BLUEC} Migrated addon ${YELLOWC}${addon_name}${BLUEC} : ${GREENC} OK${NC} " ;
954
+ done
955
+ }
956
+
902
957
function ci_command {
903
958
local usage="
904
959
This command provides subcommands useful in CI (Continious Integration) process
905
960
906
961
NOTE: This command is experimental and everything may be changed.
907
962
908
963
Usage:
909
- $SCRIPT_NAME ci check-versions-git [--help] - ensure versions of changed addons were updated
910
- $SCRIPT_NAME ci fix-versions [--help] - fix versions of changed addons
911
- $SCRIPT_NAME ci ensure-icons [--help] - ensure all addons in specified directory have icons
912
- $SCRIPT_NAME ci ensure-changelog [--help] - ensure that changes described in changelog
913
- $SCRIPT_NAME ci push-changes [--help] - push changes to same branch
914
- $SCRIPT_NAME ci do-forward-port [--help] - do forwardport
915
- $SCRIPT_NAME ci do-fwp [--help] - alias to 'do-forward-port'
916
- $SCRIPT_NAME ci do-fp [--help] - alias to 'do-forward-port'
917
- $SCRIPT_NAME ci do-fw [--help] - alias to 'do-forward-port'
918
- $SCRIPT_NAME ci -h|--help|help - show this help message
964
+ $SCRIPT_NAME ci check-versions-git [--help] - ensure versions of changed addons were updated
965
+ $SCRIPT_NAME ci fix-versions [--help] - fix versions of changed addons
966
+ $SCRIPT_NAME ci ensure-icons [--help] - ensure all addons in specified directory have icons
967
+ $SCRIPT_NAME ci ensure-changelog [--help] - ensure that changes described in changelog
968
+ $SCRIPT_NAME ci push-changes [--help] - push changes to same branch
969
+ $SCRIPT_NAME ci do-forward-port [--help] - do forwardport
970
+ $SCRIPT_NAME ci do-fwp [--help] - alias to 'do-forward-port'
971
+ $SCRIPT_NAME ci do-fp [--help] - alias to 'do-forward-port'
972
+ $SCRIPT_NAME ci do-fw [--help] - alias to 'do-forward-port'
973
+ $SCRIPT_NAME ci auto-migrate-modules [--help] - automatically try to migrate modules to current version
974
+ $SCRIPT_NAME ci -h|--help|help - show this help message
919
975
" ;
920
976
921
977
if [[ $# -lt 1 ]]; then
@@ -957,6 +1013,11 @@ function ci_command {
957
1013
ci_do_forwardport " $@ " ;
958
1014
return ;
959
1015
;;
1016
+ auto-migrate-modules)
1017
+ shift ;
1018
+ ci_auto_migrate_modules " $@ " ;
1019
+ return ;
1020
+ ;;
960
1021
-h|--help|help)
961
1022
echo " $usage " ;
962
1023
return 0;
0 commit comments