The vet clinic example is painfully common. Eight months of hourly work, a tool that solves a real problem across ten locations, and then the freelancer learns that "all work product" in the contract covered the reusable pieces too.
What I take from it is that ownership is a scoping question. If a developer expects to reuse a component, that has to be written down before the work starts, along with what the client gets, such as a perpetual licence or a discount. Raising it after the tool works feels like a grab, even when the request is fair.
Hourly billing makes this harder because nobody ever defines the deliverable, so nobody defines what sits outside it.
At Ascendra Ventures we agree one defined outcome at a fixed price and list what the client owns as part of that scope. Did the clinic chain end up open to a licence deal, or was the product idea dropped?