From 3d14e7ac6591f33489f67a19c9a67bd3e7ff4268 Mon Sep 17 00:00:00 2001 From: Janik von Rotz Date: Fri, 22 May 2026 12:03:21 +0200 Subject: [PATCH] feat(task): add generate-module-wizard function and wizard.py template --- task | 26 ++++++++++++++++++++++++-- templates/wizard.py | 15 +++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 templates/wizard.py diff --git a/task b/task index dbd573d8..08def950 100755 --- a/task +++ b/task @@ -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.' diff --git a/templates/wizard.py b/templates/wizard.py new file mode 100644 index 00000000..5dd4a19d --- /dev/null +++ b/templates/wizard.py @@ -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') \ No newline at end of file