First of all, use helper functions or explicit for loops.
E.g. you're looping over m.tm four times. This can be done in a single loop. It might need more lines of code, but it will get much more readable.
E.g.
def res_stock_total_rule(m, co, co_type):
if not co in m.co_stock:
return Constraint.Skip
val = 0
for tm in m.tm: # one single loop instead of four
for p in m.pro_tuples:
if p[1] == co:
val += m.e_pro_in[(tm,) + p)]
if p[2] == co:
val += m.e_pro_out[(tm,) + p)]
for s in m.sto_tuples: # one single loop instead of two
if s[1] == co:
val += m.e_sto_out[(tm,) + p)] - m.e_sto_in[(tm,) + p)]
return val <= m.commodity.loc[co, co_type]['max']