As this question demonstrates that the sum of idempotents is idempotent iff every pairwise product is zero, for finite matrices with complex entries.

What additional restrictions do we need to put in for this to remain true in commutative ring theory? Of course the same trivial direction remains trivial, it just that the other direction , I would hazard restricts what kinds of rings we can use.