Cook beans: Drain, place the beans, one halved and unpeeled onion, the carrot, and 1 bay leaf in a large pot, cover with plenty of water. Bring to a boil, lower the heat and simmer until the beans are soft. The cooking time depends on the size and age of the beans. Small beans will need at least 40 minutes, larger ones longer.
Drain the beans reserving the cooking liquid, and discard the onion and the carrot.
Chop the second onion, red pepper, garlic, and tomatoes.
Cook stew: Heat the oil in a pan and braise the onion lightly, adding a little bit of salt. Add the pepper, tomatoes, garlic, and cooked beans and stir well. Add some cooking liquid, enough to almost cover the beans and vegetables. Add the second bay leaf and the vegetable stock cube. Cook until the vegetables are soft, about 20 minutes or so.
Thicken bean stew: In a small bowl, mix the flour, tomato paste, and enough cooking liquid to form a runny paste. Slowly drizzle in the stew while whisking all the time. Whisk on the outer surface of the sauce and use a wooden spoon to mix everything well afterward. You might not need all the paste; incorporate it little by little in the sauce until you get the desired consistency.
Adjust taste: Stir thoroughly and bring everything to a boil again. Cook for a couple of minutes, adjust the taste with salt and pepper, and remove from the heat.
Notes
You can thicken the sauce with corn starch instead of flour if you prefer it.