from odoo import models, fields, api


class LogisticsGraphWizard(models.TransientModel):
    _name = 'logistics.graph.wizard'
    _description = 'Add Node to Graph Wizard'

    node_id = fields.Many2one(
        'logistics.node',
        string='Logistics Node',
        required=True
    )
    
    node_uuid = fields.Char(
        string='Node UUID',
        required=True
    )
    
    country_id = fields.Many2one('res.country', string='Country', required=True)
    
    graph_method = fields.Selection([
        ('geodesic', 'Geodesic'),
        ('isochrone', 'Isochrone'),
    ], string='Graph Method', default='geodesic', required=True)
    
    duration_minutes = fields.Integer(
        string='Duration (minutes)',
        default=1200
    )

    def action_add_to_graph(self):
        """Add node to graph with selected method"""
        node = self.node_id
        node._trigger_graph_creation(self.graph_method, self.duration_minutes)
        return {'type': 'ir.actions.act_window_close'}