Barium and yttrium abundance in intermediate-age and old open clusters