Forráskód Böngészése

Feature MMIWorkflow : Add Option to create automatically order from propal only if not already exists

Mathieu Moulin 2 éve
szülő
commit
0faddeccdd

+ 6 - 0
htdocs/admin/workflow.php

@@ -65,6 +65,12 @@ $workflowcodes = array(
 		'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)),
 		'picto'=>'order'
 	),
+	'WORKFLOW_PROPAL_AUTOCREATE_ORDER_IFNOTEXISTS'=>array(
+		'family'=>'create',
+		'position'=>11,
+		'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)),
+		'picto'=>'order'
+	),
 	'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array(
 		'family'=>'create',
 		'position'=>20,

+ 8 - 0
htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php

@@ -72,6 +72,14 @@ class InterfaceWorkflowManager extends DolibarrTriggers
 		if ($action == 'PROPAL_CLOSE_SIGNED') {
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
 			if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) {
+				// Added by MMI Mathieu Moulin iProspective
+				// Check if there is already one
+				if (!empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER_IFNOTEXISTS)) {
+					$object->fetchObjectLinked();
+					if (!empty($object->linkedObjectsIds['commande']))
+						return $ret;
+				}
+				
 				include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
 				$newobject = new Commande($this->db);
 

+ 1 - 0
htdocs/langs/en_US/workflow.lang

@@ -4,6 +4,7 @@ WorkflowDesc=This module provides some automatic actions. By default, the workfl
 ThereIsNoWorkflowToModify=There is no workflow modifications available with the activated modules.
 # Autocreate
 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_ORDER_IFNOTEXISTS=Automatically create a sales order after a commercial proposal is signed only if the is no order already linked to 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
 descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a sales order is closed (the new invoice will have same amount as the order)

+ 1 - 0
htdocs/langs/fr_FR/workflow.lang

@@ -4,6 +4,7 @@ WorkflowDesc=Ce module est conçu pour modifier le comportement des actions auto
 ThereIsNoWorkflowToModify=Il n'y a pas de modifications de workflow disponibles avec les modules activés.
 # Autocreate
 descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Créer automatiquement une commande client à la signature d'un proposition commerciale (la commande sera du même montant que la proposition commerciale)
+descWORKFLOW_PROPAL_AUTOCREATE_ORDER_IFNOTEXISTS=Créer automatiquement une commande client à la signature d'un proposition commerciale seulement si il n'y a pas déjà une commande liée à la proposition
 descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Créer automatiquement une facture client à la signature d'une proposition commerciale (la facture sera du même montant que la proposition commerciale source)
 descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la validation d'un contrat
 descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Créer automatiquement une facture client à la cloture d'un commande (la facture sera du même montant que la commande)