What you are wanting is "cargo distribution", or cargodist. It can be enabled from the main menu by clicking on "Settings", then Environment -> Cargo Distribution.
More information here: https://wiki.openttd.org/Cargodist
"Cargodest" (formally "Yet Another Cargo Destinations patch", or YACD
) is the name of a somewhat similar concept that was being worked on several years ago, but whose development was stopped by its author in favor of cargodist. You can still download a copy of OpenTTD with cargodest included, but keep in mind that it is a 7 year-old copy of OpenTTD that is incompatible with playing online against other players (unless they have the same exact version), and it is likely not to be able to use many current NewGRFs due to changes in code. It also is not complete and is known to be buggy.