Fix: bug preventing creation of predefined invoice.
Also added phpunit test to detect it if it occurs again.
Merge branch '3.4' of https://github.com/Dolibarr/dolibarr.git into 3.4