In a small frying pan heat 1 tablespoon of olive oil. When hot, add the chopped onion and fry the onion until caramelized.
Meanwhile, fill a large pot with 12 cups of water (you may need to add more as your soup cooks). Once the water comes to a boil, add your celery, sweet potatoes (or squash), fennel, carrots and potatoes. Slowly add in the fried onions as well.
Cook your soup over medium heat until the vegetables are done and can easily be pierced with a sharp knife. This should take approximately about 30-40 minutes.
Carefully remove the white or yellow-flesh potatoes and place them in a small bowl with about 1/4 cup of the cooking liquid. Mash the potatoes with a potato masher or a fork and then return them to the soup pot.
With the soup still over medium heat, add in your pasta and the cod. Add the salt and pepper. Cook your soup until the pasta and cod have been cooked through; this should take between 10-15 minutes. Add up to 2 cups more water at any point if you feel your soup is too thick.
Meanwhile, in a small bowl add the lemon juice, 2 tablespoons of flour and 2 tablespoons of liquid from the pot. Stir gently until the mixture is smooth. Add to the soup, along with 2 tablespoons of olive oil.
Cook for an additional 5 minutes.
Remove the soup from the heat and allow it to thicken slightly for a few minutes before serving.