feat(task): add generate-module-wizard function and wizard.py template

This commit is contained in:
Janik von Rotz committed 2026-05-22 12:03:21 +02:00
1 parent 7149b307bf
commit 3d14e7ac65
2 files changed
+39 -2

No files matched your search

+24 -2
View File
@@ -2374,11 +2374,11 @@ export-module-inherit-vars() {
generate-module-model() {
if [[ -z "$1" ]]; then
echo '$1 is empty.'
echo '$1/path is empty.'
exit
fi
if [[ -z "$2" ]]; then
echo '$2 is empty.'
echo '$2/model is empty.'
exit
fi
local module_path="$1"
@@ -2390,6 +2390,28 @@ generate-module-model() {
echo "File "$module_path/models/$MODEL_NAME.py created.
}
generate-module-wizard() {
if [[ -z "$1" ]]; then
echo '$1/path is empty.'
exit
fi
if [[ -z "$2" ]]; then
echo '$2/model is empty.'
exit
fi
local module_path="$1"
echo 'Create wizard folder and init file'
mkdir -p "$module_path/wizard"
touch "$module_path/wizard/__init__.py"
echo 'Substitute wizard template'
export-module-vars "$1" "$2"
envsubst < templates/wizard.py > "$module_path/wizard/$MODEL_NAME.py"
echo "from . import $MODEL_NAME" >> "$module_path/wizard/__init__.py"
echo "File "$module_path/wizard/$MODEL_NAME.py created.
}
generate-module-translation() {
if [[ -z "$1" ]]; then
echo '$1 is empty.'
+15
View File
@@ -0,0 +1,15 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
from odoo import _, api, fields, models
_logger = logging.getLogger(__name__)
class ${MODEL_CAMEL_NAME}(models.TransientModel):
_name = "$MODEL_DOT_NAME"
_description = "$MODEL_DESCRIPTION"
document_id = fields.Many2one('$MODEL_DOT_NAME', required=True, ondelete='cascade')
wizard_line_ids = fields.One2many('$MODEL_DOT_NAME.line', 'wizard_id')