'Update the state of lunch.order based on its orderlines. Here is the logic:
- if at least one order line is cancelled, the order is set as cancelled
- if no line is cancelled but at least one line is not confirmed, the order is set as new
- if all lines are confirmed, the order is set as confirmed'

@api.one
@api.depends('order_line_ids.state')
def _compute_order_state(self):

    if (not self.order_line_ids):
        self.state = 'new'
    else:
        isConfirmed = True
        for orderline in self.order_line_ids:
            if (orderline.state == 'cancelled'):
                self.state = 'cancelled'
                return
            elif (orderline.state == 'confirmed'):
                continue
            else:
                isConfirmed = False
        if isConfirmed:
            self.state = 'confirmed'
        else:
            self.state = 'new'
    return
