From 03de8707510de11d19c3844aec8890d68a7c1223 Mon Sep 17 00:00:00 2001 From: bagtaib Date: Wed, 22 Jun 2022 16:29:15 +0200 Subject: [PATCH] NEW #21204 --- htdocs/admin/workflow.php | 6 ++++++ .../interface_20_modWorkflow_WorkflowManager.class.php | 6 ++++++ htdocs/langs/en_US/workflow.lang | 1 + 3 files changed, 13 insertions(+) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 47e6e87a244..4c7339f8520 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -65,6 +65,12 @@ $workflowcodes = array( 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), 'picto'=>'order' ), + 'WORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS'=>array( + 'family'=>'create', + 'position'=>15, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( 'family'=>'create', 'position'=>20, diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 8bd1e0d647d..5dc95a0679e 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -86,8 +86,14 @@ class InterfaceWorkflowManager extends DolibarrTriggers } return $ret; } + if (!empty($conf->global->WORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS)) { + $object->fetchObjectLinked(); + if (!empty($object->linkedObjectsIds['commande'])) + return $ret; + } } + // Order to invoice if ($action == 'ORDER_CLOSE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 803a31c9646..15c8b75d3ed 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -3,6 +3,7 @@ WorkflowSetup=Workflow module setup WorkflowDesc=This module provides some automatic actions. By default, the workflow is open (you can do things in the order you want) but here you can activate some automatic actions. ThereIsNoWorkflowToModify=There is no workflow modifications available with the activated modules. # Autocreate +descWORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS=Do not Automatically create a sales order after a commercial proposal is signed if it already exists descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a sales order after a commercial proposal is signed (the new order will have same amount as the proposal) descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (the new invoice will have same amount as the proposal) descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated