Fix a deadlock situation. If order set to billed by error, no way to
solve situation.
This commit is contained in:
parent
4870cd7616
commit
e10db62b3a
@ -445,7 +445,15 @@ if (empty($reshook))
|
|||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($action == 'classifyunbilled' && $user->rights->commande->creer)
|
||||||
|
{
|
||||||
|
$ret=$object->classifyUnBilled();
|
||||||
|
|
||||||
|
if ($ret < 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Positionne ref commande client
|
// Positionne ref commande client
|
||||||
else if ($action == 'set_ref_client' && $user->rights->commande->creer) {
|
else if ($action == 'set_ref_client' && $user->rights->commande->creer) {
|
||||||
$object->set_ref_client($user, GETPOST('ref_client'));
|
$object->set_ref_client($user, GETPOST('ref_client'));
|
||||||
@ -2373,7 +2381,11 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) {
|
||||||
|
if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
|
||||||
|
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
// Clone
|
// Clone
|
||||||
if ($user->rights->commande->creer) {
|
if ($user->rights->commande->creer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&object=order">' . $langs->trans("ToClone") . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&object=order">' . $langs->trans("ToClone") . '</a></div>';
|
||||||
|
|||||||
@ -2420,7 +2420,57 @@ class Commande extends CommonOrder
|
|||||||
return $this->classifyBilled();
|
return $this->classifyBilled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classify the order as not invoiced
|
||||||
|
*
|
||||||
|
* @return int <0 if ko, >0 if ok
|
||||||
|
*/
|
||||||
|
function classifyUnBilled()
|
||||||
|
{
|
||||||
|
global $conf, $user, $langs;
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 0';
|
||||||
|
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG);
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user);
|
||||||
|
if ($result < 0) $error++;
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->facturee=0; // deprecated
|
||||||
|
$this->billed=0;
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach($this->errors as $errmsg)
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR);
|
||||||
|
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||||
|
}
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1*$error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a line in database
|
* Update a line in database
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user