Repository: SplashSync/Dolibarr
Module version: 2.23.3 (also present in 2.21.0 — file unchanged between the two)
Dolibarr: 23.0.0
Summary
deleteItem() forces the order into draft state so Dolibarr will accept a line deletion, but it
sets the deprecated $object->statut property. Since Dolibarr renamed the property to
$object->status, Commande::deleteLine() no longer reads what Splash sets, and every line
deletion is refused.
Error
Splash\Local\Objects\Order::deleteItem() => Error :
Supprimer une ligne n'est pas autorisée par l'état actuel de l'objet
(ErrorDeleteLineNotAllowedByObjectStatus)
Root cause
src/Objects/Order/ItemsTrait.php:52-65
protected function deleteItem(OrderLine $orderLine): bool
{
global $user;
//====================================================================//
// Force Order Status To Draft
$this->object->statut = 0; // <-- deprecated property
//====================================================================//
// Perform Line Delete
if ($this->object->deleteline($user, $orderLine->id) <= 0) {
return $this->catchDolibarrErrors();
}
return true;
}
Dolibarr 23 — htdocs/commande/class/commande.class.php:2489:
public function deleteLine($user = null, $lineid = 0, $id = 0)
{
if ($this->status == self::STATUS_DRAFT) { // <-- reads ->status, not ->statut
...
} else {
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
return -1;
}
}
->statut is still declared for backward compatibility but is no longer what the guard reads, so
the forced draft state has no effect.
Consequence
Extra lines in Dolibarr can never be removed by a sync. On our instance, WooCommerce orders whose
fee lines had been recalculated at checkout kept their obsolete lines in Dolibarr permanently — the
Dolibarr order total stayed above the real WooCommerce total, and no re-sync could fix it.
Steps to reproduce
- Dolibarr 22 or 23.
- Sync an order, then remove a line on the shop side.
- Re-sync: Splash tries to delete the extra line and is refused.
Suggested fix
// Force Order Status To Draft
$this->object->statut = 0;
+$this->object->status = 0;
Setting both keeps compatibility with older Dolibarr versions that still read ->statut.
A broader sweep for ->statut = assignments elsewhere in the module may be worthwhile.
Repository: SplashSync/Dolibarr
Module version: 2.23.3 (also present in 2.21.0 — file unchanged between the two)
Dolibarr: 23.0.0
Summary
deleteItem()forces the order into draft state so Dolibarr will accept a line deletion, but itsets the deprecated
$object->statutproperty. Since Dolibarr renamed the property to$object->status,Commande::deleteLine()no longer reads what Splash sets, and every linedeletion is refused.
Error
Root cause
src/Objects/Order/ItemsTrait.php:52-65Dolibarr 23 —
htdocs/commande/class/commande.class.php:2489:->statutis still declared for backward compatibility but is no longer what the guard reads, sothe forced draft state has no effect.
Consequence
Extra lines in Dolibarr can never be removed by a sync. On our instance, WooCommerce orders whose
fee lines had been recalculated at checkout kept their obsolete lines in Dolibarr permanently — the
Dolibarr order total stayed above the real WooCommerce total, and no re-sync could fix it.
Steps to reproduce
Suggested fix
// Force Order Status To Draft $this->object->statut = 0; +$this->object->status = 0;Setting both keeps compatibility with older Dolibarr versions that still read
->statut.A broader sweep for
->statut =assignments elsewhere in the module may be worthwhile.