The vendor reference you enter is not saved

In Dolibarr 24.0.x, the reference entered on a purchase order is lost if the product has no buying price with that vendor. Two workarounds.

Versions concerned
Dolibarr 24.0.x · fix present in the development branch
What was checked
Reproduced on a 24.0.0 Docker instance, from the purchase order web page. Development branch fix applied then removed, original file restored.

You add a line to a purchase order, you enter the product’s reference at that vendor in the field provided, you confirm. The line is added, and the reference is empty. You try again, same result.

The exact case

The problem occurs when the product has no buying price recorded for that vendor. In that case, the code that saves the line does not take the reference entered in the form: it looks for it on the vendor price side, which does not exist, and therefore saves an empty value.

You sometimes read that a product cannot be ordered without a vendor reference, unless you use a free-text line. That is not accurate: the line is added perfectly well. It is only the reference you entered that gets lost along the way.

How this was verified

On a 24.0.0 Docker instance, with a product without a vendor price and a reference typed into the form on the order page — the real web page, not a command-line call or an API request.

  • Before the fix: line added, reference saved empty in the database.
  • After the fix (three lines added in the order page): the reference entered is indeed saved.
  • Original file restored and test lines removed after the trial.

The fix present in the project’s development branch (contribution no. 40152) has not been carried over into the 24.0 branch: the line concerned still has no fallback there. In other words, the fix exists, but it is not yet in the version you are using.

The two workarounds

Enter a buying price on the product. The simplest option, and without touching the code: create the vendor price for this product, even an approximate one. The reference is then picked up correctly. It is also good practice if you want your margins to mean something.

Apply the fix by hand. If you are comfortable with a PHP file and know how to put it back as it was, the development branch fix applies to the purchase order page. Tested, it works. Back up the original file, and make a note of it somewhere: an upgrade will overwrite it.

The takeaway

When data you entered disappears without an error message, first look at what the code fetches instead of your input. There is often a source considered more reliable than the form — and it is empty.

Dolibarrpurchase ordervendor referencebuying price24