# Generated by Django 5.2.7 on 2025-11-05 23:20

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


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0083_alter_odooprofile_options_odooprofile_crm"),
        ("nodes", "0026_alter_node_port"),
        ("ocpp", "0037_cpfirmware_cpfirmwaredeployment"),
    ]

    operations = [
        migrations.CreateModel(
            name="ManualTask",
            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)),
                ("title", models.CharField(max_length=200, verbose_name="Title")),
                (
                    "description",
                    models.TextField(
                        help_text="Detailed summary of the work to perform.",
                        verbose_name="Description",
                    ),
                ),
                (
                    "scheduled_start",
                    models.DateTimeField(
                        help_text="Planned start time for this work.",
                        verbose_name="Scheduled start",
                    ),
                ),
                (
                    "scheduled_end",
                    models.DateTimeField(
                        help_text="Planned completion time for this work.",
                        verbose_name="Scheduled end",
                    ),
                ),
                (
                    "location",
                    models.ForeignKey(
                        blank=True,
                        help_text="Charge point location associated with this manual task.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="manual_tasks",
                        to="ocpp.location",
                        verbose_name="Charge Location",
                    ),
                ),
                (
                    "node",
                    models.ForeignKey(
                        blank=True,
                        help_text="Node where this manual task should be completed.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="manual_tasks",
                        to="nodes.node",
                        verbose_name="Node",
                    ),
                ),
            ],
            options={
                "verbose_name": "Manual Task",
                "verbose_name_plural": "Manual Tasks",
                "ordering": ("scheduled_start", "title"),
                "constraints": [
                    models.CheckConstraint(
                        condition=models.Q(
                            ("node__isnull", False),
                            ("location__isnull", False),
                            _connector="OR",
                        ),
                        name="manualtask_requires_target",
                    ),
                    models.CheckConstraint(
                        condition=models.Q(
                            ("scheduled_end__gte", models.F("scheduled_start"))
                        ),
                        name="manualtask_schedule_order",
                    ),
                ],
            },
        ),
    ]
