Remove the skin from the onions and slice thinly (remove the green core if there is any).
Transfer to a large bowl with half the sugar, cover with cold water, and stir.
Let stand for 30 minutes, then change the water, add the rest of the sugar, stir, and stand for another 30 minutes.
Once the onions are drained, place the olive oil and onion in a high-sided pan. Cook them gently, stirring occasionally, for about 1 hour.
Remove the lid and cook for 15 minutes on a medium-small stove over low heat, stirring until any liquid from the onions has completely evaporated.
Add tomato sauce, salt, water, and more olive oil if needed and mix (at this point, I usually add another 20 g of oil). Also, add sugar or apricot jam and stir. Cook with the pan covered and over low heat for one hour or as long as needed if the sauce is too slow. Conversely, if it seems too thick, add a little water. If you like it more stewed, cook it for 2 hours.
Let rest, taste, and adjust the salt.