diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 097b35c2f92..bdd14490d64 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -83,6 +83,8 @@ if ($id > 0 || ! empty($ref))
{
$resObj = $object->fetch($id, $ref);
$resTP = $object->fetch_thirdparty();
+ if ($resObj < 0) dol_print_error($db,$object->error);
+ if ($resTP < 0) dol_print_error($db,$object->error);
}
/*
@@ -201,9 +203,6 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
if (! $error && (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])))
{
- if ($resObj < 0) dol_print_error($db,$object->error);
- if ($resTP < 0) dol_print_error($db,$object->error);
-
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
@@ -732,7 +731,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
{
$langs->load('mails');
- if ($resObj > 0)
+ if ($resObj)
{
// $ref = dol_sanitizeFileName($object->ref);
// $file = $conf->fournisseur->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
@@ -961,8 +960,6 @@ if ($id > 0 || ! empty($ref))
//if ($mesg) print $mesg.'
';
if ($result >= 0)
{
- $soc = &$object->thirdparty;
-
$author = new User($db);
$author->fetch($object->user_author_id);
@@ -1000,7 +997,7 @@ if ($id > 0 || ! empty($ref))
$object->date_commande=dol_now();
// We check if number is temporary number
- if (preg_match('/^[\(]?PROV/i',$object->ref)) $newref = $object->getNextNumRef($soc);
+ if (preg_match('/^[\(]?PROV/i',$object->ref)) $newref = $object->getNextNumRef($object->thirdparty);
else $newref = $object->ref;
$text=$langs->trans('ConfirmValidateOrder',$newref);
@@ -1106,7 +1103,7 @@ if ($id > 0 || ! empty($ref))
// Fournisseur
print '