For farms, factories, and research buildings to get the bonus, the building must actually produce something. Farms get the bonus, food distribution center does not. For odd things like the torian building in TA that gives both farm output and farm output % boost, the direct output gets the bonus and the % boost applies to the bonus-adjusted production.
Morale and influence buildings that affect ONLY THAT PLANET get the bonus. Embassies, entertainment buildings, counter espionage center, even stock markets can use these bonuses. The political capitol can use either of these bonuses. Special buildings that affect your entire empire cannot use these bonuses, so don't bother putting the Restaurant of Eternity or Harmony Crystals on one.