removed the new option and enhanced the old one

This commit is contained in:
bagtaib 2022-06-23 15:37:37 +02:00
parent 03de870751
commit cc0be635dc
4 changed files with 21 additions and 26 deletions

View File

@ -65,12 +65,6 @@ $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,

View File

@ -72,27 +72,28 @@ 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)) {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$newobject = new Commande($this->db);
$newobject->context['createfrompropal'] = 'createfrompropal';
$newobject->context['origin'] = $object->element;
$newobject->context['origin_id'] = $object->id;
$ret = $newobject->createFromProposal($object, $user);
if ($ret < 0) {
$this->error = $newobject->error;
$this->errors[] = $newobject->error;
}
return $ret;
}
if (!empty($conf->global->WORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS)) {
$object->fetchObjectLinked();
if (!empty($object->linkedObjectsIds['commande']))
if (!empty($object->linkedObjectsIds['commande'])){
setEventMessages($langs->trans("OrderExists"), null, 'warnings');
return $ret;
}
}
}
else {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$newobject = new Commande($this->db);
$newobject->context['createfrompropal'] = 'createfrompropal';
$newobject->context['origin'] = $object->element;
$newobject->context['origin_id'] = $object->id;
$ret = $newobject->createFromProposal($object, $user);
if ($ret < 0) {
$this->error = $newobject->error;
$this->errors[] = $newobject->error;
}
return $ret;
}
}
}
// Order to invoice
if ($action == 'ORDER_CLOSE') {

View File

@ -1,4 +1,5 @@
# Dolibarr language file - Source file is en_US - orders
OrderExists=An order was already open linked to this proposal, so no other order was created automatically
OrdersArea=Customers orders area
SuppliersOrdersArea=Purchase orders area
OrderCard=Order card

View File

@ -3,7 +3,6 @@ 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