From 768846191b0a92f4ebd473ffddd2ea485670e6da Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Sat, 27 Apr 2024 12:49:27 +0200 Subject: [PATCH] fix: when invoice is created by WORKFLOW_ORDER_AUTOCREATE_INVOICE on ORDER_CLOSE, the invoice must have the default bank account of the thirdparty is it's empty on order (#29462) * fix: when invoice is created by WORKFLOW_ORDER_AUTOCREATE_INVOICE on ORDER_CLOSE, the invoice must have the default bank account of the thirdparty is it's empty on order * fix: add control on back stattement --- .../interface_20_modWorkflow_WorkflowManager.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index f85a26697b717..c7fa2290f1821 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -116,6 +116,14 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($ret < 0) { $this->error = $newobject->error; $this->errors[] = $newobject->error; + } else { + if (empty($object->fk_account) && !empty($object->thirdparty->fk_account) && !getDolGlobalInt('BANK_ASK_PAYMENT_BANK_DURING_ORDER')) { + $res = $newobject->setBankAccount($object->thirdparty->fk_account, true, $user); + if ($ret < 0) { + $this->error = $newobject->error; + $this->errors[] = $newobject->error; + } + } } $object->clearObjectLinkedCache();