<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2024-2026 Nexa Systems Inc.
    License OPL-1 (Odoo Proprietary License v1.0)
-->
<odoo>
    <data>

        <!-- Cron Job: Calculate Travel Times for Technician Tasks (every 15 min) -->
        <record id="ir_cron_technician_travel_times" model="ir.cron">
            <field name="name">Fusion Tasks: Calculate Technician Travel Times</field>
            <field name="model_id" ref="model_fusion_technician_task"/>
            <field name="state">code</field>
            <field name="code">model._cron_calculate_travel_times()</field>
            <field name="interval_number">15</field>
            <field name="interval_type">minutes</field>
            <field name="active">True</field>
        </record>

        <!-- Cron Job: Send Push Notifications for Upcoming Tasks -->
        <record id="ir_cron_technician_push_notifications" model="ir.cron">
            <field name="name">Fusion Tasks: Technician Push Notifications</field>
            <field name="model_id" ref="model_fusion_technician_task"/>
            <field name="state">code</field>
            <field name="code">model._cron_send_push_notifications()</field>
            <field name="interval_number">15</field>
            <field name="interval_type">minutes</field>
            <field name="active">True</field>
        </record>

        <!-- Cron Job: Pull Remote Technician Tasks (cross-instance sync) -->
        <record id="ir_cron_task_sync_pull" model="ir.cron">
            <field name="name">Fusion Tasks: Sync Remote Tasks (Pull)</field>
            <field name="model_id" ref="model_fusion_task_sync_config"/>
            <field name="state">code</field>
            <field name="code">model._cron_pull_remote_tasks()</field>
            <field name="interval_number">2</field>
            <field name="interval_type">minutes</field>
            <field name="active">True</field>
        </record>

        <!-- Cron Job: Cleanup Old Shadow Tasks (30+ days) -->
        <record id="ir_cron_task_sync_cleanup" model="ir.cron">
            <field name="name">Fusion Tasks: Cleanup Old Shadow Tasks</field>
            <field name="model_id" ref="model_fusion_task_sync_config"/>
            <field name="state">code</field>
            <field name="code">model._cron_cleanup_old_shadows()</field>
            <field name="interval_number">1</field>
            <field name="interval_type">days</field>
            <field name="active">True</field>
            <field name="nextcall" eval="DateTime.now().replace(hour=3, minute=0, second=0)"/>
        </record>

        <!-- Cron Job: Check for Late Technician Arrivals -->
        <record id="ir_cron_check_late_arrivals" model="ir.cron">
            <field name="name">Fusion Tasks: Check Late Technician Arrivals</field>
            <field name="model_id" ref="model_fusion_technician_task"/>
            <field name="state">code</field>
            <field name="code">model._cron_check_late_arrivals()</field>
            <field name="interval_number">10</field>
            <field name="interval_type">minutes</field>
            <field name="active">True</field>
        </record>

        <!-- Cron Job: Cleanup Old Technician Locations -->
        <record id="ir_cron_cleanup_locations" model="ir.cron">
            <field name="name">Fusion Tasks: Cleanup Old Locations</field>
            <field name="model_id" ref="model_fusion_technician_location"/>
            <field name="state">code</field>
            <field name="code">model._cron_cleanup_old_locations()</field>
            <field name="interval_number">1</field>
            <field name="interval_type">days</field>
            <field name="active">True</field>
            <field name="nextcall" eval="DateTime.now().replace(hour=4, minute=0, second=0)"/>
        </record>

    </data>
</odoo>
