Your door locks are controlled by the body control module. It monitors the amount of current draw on the lock and unlock circuits, and when the draw goes across a threshold it will disable the locks to preserve itself from internal damage. It sets a fault code and doesn't allow the locks to work again until the code is cleared, this is why the locks works again after you disconnect the battery
or pull the IOD fuse. Doing this clears the fault code.
The original BCM software was a little sensitive and could disable the locks a little prematurely. There was a revision to the BCM software to make it more fault tolerant so this wouldn't happen as easily. The fix is to have your BCM software reprogrammed to the current software version. This will have to be done by a dealer and will take about a half hour to complete.
Pull the IOD (BCM) fuse to reset the system. See if this will fix the door locks, at least for some time. The IOD fuse is on the left side of the fuse box under the hood, it is a 15 AMP fuse.