# Generated by Django 5.2.10 on 2026-01-24 22:34

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("odoo", "0006_alter_odooemployee_group_alter_odooemployee_user"),
    ]

    operations = [
        migrations.CreateModel(
            name="OdooQuery",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("name", models.CharField(max_length=255, unique=True)),
                ("description", models.TextField(blank=True)),
                (
                    "model_name",
                    models.CharField(
                        help_text="Target Odoo model name, e.g. sale.order.",
                        max_length=255,
                        verbose_name="Odoo Model",
                    ),
                ),
                (
                    "method",
                    models.CharField(
                        default="search_read",
                        help_text="Odoo RPC method to execute.",
                        max_length=100,
                    ),
                ),
                (
                    "kwquery",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Keyword arguments for the Odoo RPC call.",
                    ),
                ),
                ("enable_public_view", models.BooleanField(default=False)),
                (
                    "public_view_slug",
                    models.SlugField(blank=True, null=True, unique=True),
                ),
                ("public_title", models.CharField(blank=True, max_length=255)),
                ("public_description", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "profile",
                    models.ForeignKey(
                        blank=True,
                        help_text="Odoo employee profile used to execute this query.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="queries",
                        to="odoo.odooemployee",
                    ),
                ),
            ],
            options={
                "verbose_name": "Odoo Query",
                "verbose_name_plural": "Odoo Queries",
                "db_table": "core_odooquery",
                "ordering": ("name",),
            },
        ),
        migrations.CreateModel(
            name="OdooQueryVariable",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "key",
                    models.SlugField(help_text="Identifier used in [VAR.key] sigils."),
                ),
                ("label", models.CharField(max_length=100)),
                ("help_text", models.CharField(blank=True, max_length=255)),
                ("default_value", models.TextField(blank=True)),
                (
                    "input_type",
                    models.CharField(
                        choices=[
                            ("text", "Text"),
                            ("number", "Number"),
                            ("date", "Date"),
                            ("datetime", "Date & time"),
                        ],
                        default="text",
                        max_length=20,
                    ),
                ),
                ("is_required", models.BooleanField(default=False)),
                ("sort_order", models.PositiveIntegerField(default=0)),
                (
                    "query",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="variables",
                        to="odoo.odooquery",
                    ),
                ),
            ],
            options={
                "verbose_name": "Odoo Query Variable",
                "verbose_name_plural": "Odoo Query Variables",
                "db_table": "core_odooqueryvariable",
                "ordering": ("sort_order", "label"),
                "constraints": [
                    models.UniqueConstraint(
                        fields=("query", "key"), name="odooqueryvariable_unique"
                    )
                ],
            },
        ),
    ]
