diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 35ab381a35f29508d1d954c67f603551c5ae0022..9a2d5d0bc50a3dfbb74b81d5907d4603280127cb 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -365,7 +365,11 @@ else if ($action == 'add' && $user->rights->propal->creer) {
 						if ($result > 0)
 						{
 							$lines = $srcobject->lines;
-							if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines();
+							if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
+							{
+								$srcobject->fetch_lines();
+								$lines = $srcobject->lines;
+							}
 
 							$fk_parent_line=0;
 							$num=count($lines);
@@ -1283,7 +1287,9 @@ if ($action == 'create') {
 			$objectsrc = new $classname($db);
 			$objectsrc->fetch($originid);
 			if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines'))
+			{
 				$objectsrc->fetch_lines();
+			}
 			$objectsrc->fetch_thirdparty();
 
 			$projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : '');
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 1d59311404eeafe547703496b4afc6a1ecca1b03..2fda0277bec085aac58218eb2083d897d9fe261d 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -271,10 +271,12 @@ else if ($action == 'add' && $user->rights->commande->creer) {
 			if ($ret < 0)
 				$error ++;
 
-			if (! $error) {
+			if (! $error)
+			{
 				$object_id = $object->create($user);
 
-				if ($object_id > 0) {
+				if ($object_id > 0)
+				{
 					dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
 
 					$classname = ucfirst($subelement);
@@ -282,15 +284,20 @@ else if ($action == 'add' && $user->rights->commande->creer) {
 
 					dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
 					$result = $srcobject->fetch($object->origin_id);
-					if ($result > 0) {
+					if ($result > 0)
+					{
 						$lines = $srcobject->lines;
 						if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
-							$lines = $srcobject->fetch_lines();
+						{
+							$srcobject->fetch_lines();
+							$lines = $srcobject->lines;
+						}
 
 						$fk_parent_line = 0;
 						$num = count($lines);
 
-						for($i = 0; $i < $num; $i ++) {
+						for($i = 0; $i < $num; $i ++)
+						{
 							$label = (! empty($lines [$i]->label) ? $lines [$i]->label : '');
 							$desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle);
 							$product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0);
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index 8b16428b23f122920c35636607c9dec711256b28..814e52884ab5b0dd7b457260e0324681e2896a18 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -100,7 +100,7 @@ if (($action == 'create' || $action == 'add') && !$error)
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
 	if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
-	
+
 	$langs->load('bills');
 	$langs->load('products');
 	$langs->load('main');
@@ -216,13 +216,17 @@ if (($action == 'create' || $action == 'add') && !$error)
 							$result=$objectsrc->fetch($orders_id[$ii]);
 							if ($result > 0)
 							{
-								if ($closeOrders) 
+								if ($closeOrders)
 								{
 									$objectsrc->classifyBilled();
 									$objectsrc->setStatut(3);
 								}
 								$lines = $objectsrc->lines;
-								if (empty($lines) && method_exists($objectsrc,'fetch_lines'))  $lines = $objectsrc->fetch_lines();
+								if (empty($lines) && method_exists($objectsrc, 'fetch_lines'))
+								{
+									$objectsrc->fetch_lines();
+									$lines = $objectsrc->lines;
+								}
 								$fk_parent_line=0;
 								$num=count($lines);
 								for ($i=0;$i<$num;$i++)
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 67a93eadc443555143ae9edc2e3024531f96ba76..50af9c5ec1069a7b0be3ad02bccbdff970458e4c 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -933,7 +933,11 @@ else if ($action == 'add' && $user->rights->facture->creer)
 						if ($result > 0)
 						{
 							$lines = $srcobject->lines;
-							if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines();
+							if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
+							{
+								$srcobject->fetch_lines();
+								$lines = $srcobject->lines;
+							}
 
 							$fk_parent_line=0;
 							$num=count($lines);
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 38f4ba9a8c4ab4c93a1a2748671c0b4de129f3a9..165e8ae3c69bd2ebecd29a67becf62f9b476697e 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -252,7 +252,11 @@ if ($action == 'add' && $user->rights->contrat->creer)
 	            {
 	                $srcobject->fetch_thirdparty();
 					$lines = $srcobject->lines;
-	                if (empty($lines) && method_exists($srcobject,'fetch_lines'))  $lines = $srcobject->fetch_lines();
+	                if (empty($lines) && method_exists($srcobject,'fetch_lines'))
+	                {
+	                	$srcobject->fetch_lines();
+	                	$lines = $srcobject->lines;
+	                }
 
 	                $fk_parent_line=0;
 	                $num=count($lines);
@@ -339,7 +343,7 @@ if ($action == 'add' && $user->rights->contrat->creer)
 	    }
 	    else
 	    {
-	    	
+
 	    	// Fill array 'array_options' with data from add form
 	    	$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
 
@@ -717,7 +721,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
 		$error ++;
 
 	if (! $error) {
-		
+
 			$result = $object->insertExtraFields();
 			if ($result < 0) {
 				$error ++;
@@ -735,7 +739,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
 		setEventMessage($object->errors,'errors');
 	}
 	$object->ref_customer=GETPOST('ref_customer','alpha');
-	
+
 	$result = $object->update($user);
 	if ($result < 0) {
 		setEventMessage($object->errors,'errors');
@@ -750,7 +754,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
 		setEventMessage($object->errors,'errors');
 	}
 	$object->ref=GETPOST('ref','alpha');
-	
+
 	$result = $object->update($user);
 	if ($result < 0) {
 		setEventMessage($object->errors,'errors');
@@ -921,7 +925,7 @@ if ($action == 'create')
     	$tmpcode='<input name="ref" size="20" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">';
     }
 	print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$tmpcode.'</td></tr>';
-	
+
 	// Ref Int
 	print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
 	print '<td colspan="2"><input type="text" siez="5" name="ref_customer" id="ref_customer" value="'.GETPOST('ref_customer','alpha').'"></td></tr>';
@@ -999,7 +1003,7 @@ if ($action == 'create')
     // Other attributes
     $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    
+
     // Other attributes
     if (empty($reshook) && ! empty($extrafields->attribute_label)) {
     	print $object->showOptionals($extrafields, 'edit');
@@ -1181,7 +1185,7 @@ else
         // Other attributes
         $parameters=array('colspan' => ' colspan="3"');
         $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-        
+
         $res = $object->fetch_optionals($object->id, $extralabels);
         if (empty($reshook) && ! empty($extrafields->attribute_label)) {
         	foreach ($extrafields->attribute_label as $key => $label) {
@@ -1201,16 +1205,16 @@ else
         			if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
         				$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
         			}
-        
+
         			if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) {
         				print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formcontract">';
         				print '<input type="hidden" name="action" value="update_extras">';
         				print '<input type="hidden" name="attribute" value="' . $key . '">';
         				print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
         				print '<input type="hidden" name="id" value="' . $object->id . '">';
-        
+
         				print $extrafields->showInputField($key, $value);
-        
+
         				print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
         				print '</form>';
         			} else {
@@ -1222,9 +1226,9 @@ else
         		}
         	}
         }
-        
-        
-        
+
+
+
 
         print "</table>";
 
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 8f83cd1c72a46e9af906cd75f2ec5a1ccd44eefd..15b0a16a13e23b3f9b48721de70b9b21c5a42fa3 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -112,7 +112,6 @@ if ($action == 'add')
     $classname = ucfirst($object->origin);
     $objectsrc = new $classname($db);
     $objectsrc->fetch($object->origin_id);
-    //$object->fetch_lines();
 
     $object->socid					= $objectsrc->socid;
     $object->ref_customer			= $objectsrc->ref_client;
@@ -725,7 +724,6 @@ if ($action == 'create')
              * Lignes de commandes
              */
 
-            //$lines = $object->fetch_lines(1);
             $numAsked = count($object->lines);
 
             print '<script type="text/javascript" language="javascript">
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index 7e327eb896a293e544d39acd9f59fbb7f378e146..65140e726794476baad4f8ad576fb2bc9f83e5a5 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -944,9 +944,9 @@ class Fichinter extends CommonObject
 	}
 
 	/**
-	 *	Load array lines
+	 *	Load array lines ->lines
 	 *
-	 *	@return		int		<0 if Ko,	>0 if OK
+	 *	@return		int		<0 if KO, >0 if OK
 	 */
 	function fetch_lines()
 	{
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 61fe1b732bceb6f08f1b63f420f4e4fb6aea738f..0ffca1d2742b6f2474432a8e3a88e34652419abe 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -219,7 +219,11 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
 				{
 					$srcobject->fetch_thirdparty();
 					$lines = $srcobject->lines;
-					if (empty($lines) && method_exists($srcobject,'fetch_lines'))  $lines = $srcobject->fetch_lines();
+					if (empty($lines) && method_exists($srcobject,'fetch_lines'))
+					{
+						$srcobject->fetch_lines();
+						$lines = $srcobject->lines;
+					}
 
 					$fk_parent_line=0;
 					$num=count($lines);
@@ -964,7 +968,11 @@ if ($action == 'create')
 			$classname = ucfirst($subelement);
 			$objectsrc = new $classname($db);
 			$objectsrc->fetch(GETPOST('originid'));
-			if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines'))  $objectsrc->fetch_lines();
+			if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines'))
+			{
+				$objectsrc->fetch_lines();
+				$lines = $objectsrc->lines;
+			}
 			$objectsrc->fetch_thirdparty();
 
 			$projectid          = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:'');
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 4f8d6700e3593f75c6ac4267ad1a56dff887cbc5..d0dbc36e803cc538fd9210bcd46306ac3dff6d28 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -364,7 +364,11 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
                 if ($result > 0)
                 {
                     $lines = $srcobject->lines;
-                    if (empty($lines) && method_exists($srcobject,'fetch_lines'))  $lines = $srcobject->fetch_lines();
+                    if (empty($lines) && method_exists($srcobject,'fetch_lines'))
+                    {
+                    	$srcobject->fetch_lines();
+                    	$lines = $srcobject->lines;
+                    }
 
                     $num=count($lines);
                     for ($i = 0; $i < $num; $i++)
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index 7db42b6ac44946bce71fc92f35d791736993804c..ffa178629398d08f20d1f9574ec9c0fc261c4b7f 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -148,7 +148,7 @@ class Livraison extends CommonObject
 				{
 					$commande = new Commande($this->db);
 					$commande->id = $this->commande_id;
-					$this->lines = $commande->fetch_lines();
+					$commande->fetch_lines();
 				}
 
 
diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php
index c3b7e7da1c767e19ca989e881f90d0ef6bd09991..8b91b916e0bd11fb68414537075d42cca65b5567 100644
--- a/htdocs/livraison/fiche.php
+++ b/htdocs/livraison/fiche.php
@@ -185,7 +185,7 @@ if ($action == 'builddoc')	// En get ou en post
 	$object = new Livraison($db);
 	$object->fetch($id);
 	$object->fetch_thirdparty();
-	
+
 	// Save last template used to generate document
 	if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
 
@@ -317,7 +317,8 @@ if ($action == 'create')
 		 */
 		print '<br><table class="noborder" width="100%">';
 
-		$lines = $commande->fetch_lines(1);
+		$commande->fetch_lines(1);
+		$lines = $commande->lines;
 
 		// Lecture des livraisons deja effectuees
 		$commande->livraison_array();
@@ -515,7 +516,7 @@ else
 			if (($delivery->origin == 'shipment' || $delivery->origin == 'expedition') && $delivery->origin_id > 0)
 			{
 				$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/liste.php">'.$langs->trans("BackToList").'</a>';
-				
+
 				// Ref
 				print '<tr><td width="20%">'.$langs->trans("RefSending").'</td>';
 				print '<td colspan="3">';
@@ -523,8 +524,8 @@ else
 				//print $form->showrefnav($expedition, 'refshipment', $linkback, 1, 'ref', 'ref');
 				print $form->showrefnav($expedition, 'refshipment', $linkback, 0, 'ref', 'ref');
 				print '</td></tr>';
-			}			
-				
+			}
+
 			// Ref
 			print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
 			print '<td colspan="3">'.$delivery->ref.'</td></tr>';
diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index c4ca544d861a04d331476ea8cc1833528f7f416c..c1ceb4faa8ea89b687c697fa3b97748ad846e3e1 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -149,7 +149,7 @@ class Opensurveysondage extends CommonObject
 
                 // Call trigger
                 $result=$this->call_trigger('OPENSURVEY_CREATE',$user);
-                if ($result < 0) $error++;          
+                if ($result < 0) $error++;
                 // End call triggers
 			}
         }
@@ -343,7 +343,7 @@ class Opensurveysondage extends CommonObject
 			{
                 // Call trigger
                 $result=$this->call_trigger('OPENSURVEY_DELETE',$user);
-                if ($result < 0) $error++;          
+                if ($result < 0) $error++;
                 // End call triggers
 			}
 		}
@@ -387,7 +387,7 @@ class Opensurveysondage extends CommonObject
 	/**
 	 * Return array of lines
 	 *
-	 * @return 	array	Array of lines
+	 * @return 	int		<0 if KO, >0 if OK
 	 */
 	function fetch_lines()
 	{
@@ -413,7 +413,7 @@ class Opensurveysondage extends CommonObject
 
 		$this->lines=$ret;
 
-		return $this->lines;
+		return count($this->lines);
 	}
 
 	/**
diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/opensurvey/public/studs.php
index c85a62ae61a9ca5634e7ab34d262585aa69199c5..9b9f2e9ef8cd7ca70f5675fe5ded20700c03bdc9 100644
--- a/htdocs/opensurvey/public/studs.php
+++ b/htdocs/opensurvey/public/studs.php
@@ -43,7 +43,7 @@ $object=new Opensurveysondage($db);
 $result=$object->fetch(0,$numsondage);
 if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
 
-$nblignes=count($object->fetch_lines());
+$nblignes=$object->fetch_lines();
 
 //If the survey has not yet finished, then it can be modified
 $canbemodified = ($object->date_fin > dol_now());
diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php
index 63c56f9d5e31b26550d803229fb6de1386931e6d..3bfd3209343d12209c10cc8a3032987f742c7b80 100644
--- a/htdocs/opensurvey/results.php
+++ b/htdocs/opensurvey/results.php
@@ -42,7 +42,7 @@ $object=new Opensurveysondage($db);
 $result=$object->fetch(0,$numsondage);
 if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
 
-$nblignes=count($object->fetch_lines());
+$nblignes=$object->fetch_lines();
 
 
 /*