from odoo import models, fields, api

class PosOrderLine(models.Model):
    _inherit = 'pos.order.line'

    def action_mark_ready(self):
        """Override to check if we should request Uber delivery when items are ready"""
        res = super(PosOrderLine, self).action_mark_ready()
        
        for line in self:
            order = line.order_id
            # Only auto-request if it's marked as an Uber delivery type and not yet requested
            if order.delivery_type == 'uber' and not order.uber_delivery_id:
                if order._check_all_lines_ready():
                    order.action_request_uber_delivery()
        
        return res
