diff --git a/Core/Lib/AjaxForms/PurchasesController.php b/Core/Lib/AjaxForms/PurchasesController.php index 2be6ffb68e..23b1ed769e 100644 --- a/Core/Lib/AjaxForms/PurchasesController.php +++ b/Core/Lib/AjaxForms/PurchasesController.php @@ -351,7 +351,7 @@ protected function recalculateAction(bool $renderLines): bool return false; } - protected function saveDocAction(): bool + protected function saveDocAction(bool $sendOk = true): bool { $this->setTemplate(false); @@ -403,7 +403,10 @@ protected function saveDocAction(): bool return false; } - $this->sendJsonWithLogs(['ok' => true, 'newurl' => $model->url() . '&action=save-ok']); + if ($sendOk) { + $this->sendJsonWithLogs(['ok' => true, 'newurl' => $model->url() . '&action=save-ok']); + } + $this->dataBase->commit(); return true; } @@ -476,7 +479,7 @@ protected function saveStatusAction(): bool return false; } - if ($this->getModel()->editable && false === $this->saveDocAction()) { + if ($this->getModel()->editable && false === $this->saveDocAction(false)) { return false; } diff --git a/Core/Lib/AjaxForms/SalesController.php b/Core/Lib/AjaxForms/SalesController.php index 1a27a8c651..34b092ddc9 100644 --- a/Core/Lib/AjaxForms/SalesController.php +++ b/Core/Lib/AjaxForms/SalesController.php @@ -366,7 +366,7 @@ protected function recalculateAction(bool $renderLines): bool return false; } - protected function saveDocAction(): bool + protected function saveDocAction(bool $sendOk = true): bool { $this->setTemplate(false); @@ -418,7 +418,10 @@ protected function saveDocAction(): bool return false; } - $this->sendJsonWithLogs(['ok' => true, 'newurl' => $model->url() . '&action=save-ok']); + if ($sendOk) { + $this->sendJsonWithLogs(['ok' => true, 'newurl' => $model->url() . '&action=save-ok']); + } + $this->dataBase->commit(); return true; } @@ -490,7 +493,7 @@ protected function saveStatusAction(): bool return false; } - if ($this->getModel()->editable && false === $this->saveDocAction()) { + if ($this->getModel()->editable && false === $this->saveDocAction(false)) { return false; }