Using the Module Inserter mod to change modules, as well as manually putting ghost modules into the slots of a machine will have the machine reset to the last modules it had. For example, if replacing Speed Module for Productivity Module, the upgrade will cancel itself and stay with Speed Module. This will probably repeat with any module combination.
However, this issue does not happen for empty module slots. If adding Productivity Module to empty slots, they'll be applied normally both manually and with Module Inserter.
If a machine has Speed Module and an empty slot, and placing ghosts for Productivity Module on both slots, the Productivity Module will be put into the second slot but the first slot will remain with a speed module, clearing the ghost. Attempted both manually and with Module Inserter.