Merge pull request #4223 from fappels/develop-shipment-error-handling

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

View File

@ -1068,6 +1068,7 @@ class Expedition extends CommonObject
break; 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); $obj = $this->db->fetch_object($resql);
if ($this->db->jdate($obj->eatby) != $eatby) if ($this->db->jdate($obj->eatby) != $eatby)
{ {
$this->errors[]=$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->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->eatby), $eatby)); dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby)), dol_print_date($eatby)), LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }
if ($this->db->jdate($obj->sellby) != $sellby) if ($this->db->jdate($obj->sellby) != $sellby)
{ {
$this->errors[]=$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->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->sellby), $sellby)); dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }