This si an overly complicated solution. Why not just add the number of blocks of the module to the total of the ship?
The idea here is that, when docked, the module is part of the ship, it is not considered another entity anymore.
As said earlier, it would be just like adding those blocks...