[QUAL] Shipment error handling

This commit is contained in:
fappels 2015-12-14 21:38:26 +01:00
parent 7c3779f39b
commit 9fa742ceb2
3 changed files with 16 additions and 22 deletions

View File

@ -224,7 +224,7 @@ if (empty($reshook))
$ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int'));
if ($ret < 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
@ -237,7 +237,7 @@ if (empty($reshook))
$ret=$object->addline_batch($batch_line[$i]);
if ($ret < 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
@ -249,14 +249,14 @@ if (empty($reshook))
$ret=$object->create($user); // This create shipment (like Odoo picking) and line of shipments. Stock movement will when validating shipment.
if ($ret <= 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
}
else
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")).'</div>';
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("QtyToShip")), null, 'errors');
$error++;
}
@ -287,7 +287,7 @@ if (empty($reshook))
}
else
{
$mesg=$object->error;
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -337,19 +337,18 @@ if (empty($reshook))
}
else
{
$langs->load("errors");
setEventMessages($langs->trans($object->error), null, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
else if ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate)))
// TODO add alternative status
/*else if ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate)))
{
$result = $object->setStatut(0);
if ($result < 0)
{
$mesg = $object->error;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}*/
else if ($action == 'setdate_livraison' && $user->rights->expedition->creer)
{
@ -360,7 +359,7 @@ if (empty($reshook))
$result=$object->set_date_livraison($user,$datedelivery);
if ($result < 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -485,8 +484,6 @@ if ($action == 'create')
setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors');
}
dol_htmloutput_mesg($mesg);
if ($origin)
{
$classname = ucfirst($origin);
@ -928,8 +925,6 @@ else if ($id || $ref)
if ($object->id > 0)
{
dol_htmloutput_mesg($mesg);
if (!empty($object->origin))
{
$typeobject = $object->origin;
@ -943,8 +938,6 @@ else if ($id || $ref)
$head=shipping_prepare_head($object);
dol_fiche_head($head, 'shipping', $langs->trans("Shipment"), 0, 'sending');
dol_htmloutput_mesg($mesg);
/*
* Confirmation de la suppression
*/

View File

@ -1068,6 +1068,7 @@ class Expedition extends CommonObject
break;
}
}
if ($error) break; // break for loop incase of error
}
}
}

View File

@ -139,15 +139,15 @@ class MouvementStock extends CommonObject
$obj = $this->db->fetch_object($resql);
if ($this->db->jdate($obj->eatby) != $eatby)
{
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->eatby), $eatby);
dol_syslog($langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->eatby), $eatby));
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby)), dol_print_date($eatby));
dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby)), dol_print_date($eatby)), LOG_ERR);
$this->db->rollback();
return -3;
}
if ($this->db->jdate($obj->sellby) != $sellby)
{
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->sellby), $sellby);
dol_syslog($langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->sellby), $sellby));
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR);
$this->db->rollback();
return -3;
}