diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang
index 8b93ba92fb8acd678fe973857b3dd2a557238887..07fb45985d5495596d8f1e1c73f01d6d6b68e905 100644
--- a/htdocs/langs/en_US/productbatch.lang
+++ b/htdocs/langs/en_US/productbatch.lang
@@ -16,3 +16,4 @@ printEatby= Eat-by: %s
 printSellby= Sell-by: %s
 printQty= Qty: %d
 AddDispatchBatchLine=Add a line for Shelf Life dispatching
+BatchDefaultNumber= Undefined
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang
index 488e1f2fbb95c2245dfb4d01fdda4042cf706419..68e76dca46bcbe969379dab6df273cbdca3dfc95 100644
--- a/htdocs/langs/fr_FR/productbatch.lang
+++ b/htdocs/langs/fr_FR/productbatch.lang
@@ -14,4 +14,6 @@ DetailBatchFormat= C:%s UO: %s LOT: %s (Qté : %d)
 printBatch= Lot: %s
 printEatby= DLC: %s
 printSellby= DLUO: %s
-printQty= Qté: %d
\ No newline at end of file
+printQty= Qté: %d
+AddDispatchBatchLine=Ajouter une ligne de dispatch
+BatchDefaultNumber= Indéfini
\ No newline at end of file
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 32d96ec60fc7e189ea1f8761e6f4e2b6c9605c66..7a77f308509da2c1d057f4841f88be59d43c0168 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -589,6 +589,39 @@ class Product extends CommonObject
 
         if ($result >= 0)
         {
+            if (empty($this->oldcopy))
+            {
+                $org=new self($this->db);
+                $org->fetch($this->id);
+                $this->oldcopy=$org;
+            }
+            // test if batch management is activated on existing product
+            if ($this->hasbatch() && !$this->oldcopy->hasbatch())
+            {
+                $this->load_stock();
+                foreach ($this->stock_warehouse as $idW => $ObjW)
+                {
+                    $qty_batch = 0;
+                    foreach ($ObjW->detail_batch as $detail)    
+                    {
+                        $qty_batch += $detail->qty;
+                    }
+                    // Quantities in batch details are not same same as stock quantity
+                    // So we add a default batch record
+                    if ($ObjW->real <> $qty_batch)
+                    {
+                        $ObjBatch = new Productbatch($this->db);
+                        $ObjBatch->batch = $langs->trans('BatchDefaultNumber');
+                        $ObjBatch->qty = $ObjW->real - $qty_batch;
+                        $ObjBatch->fk_product_stock = $ObjW->id;
+                        if ($ObjBatch->create($user,1) < 0)
+                        { 
+                            $error++;
+                            $this->errors=$ObjBatch->errors;
+                        }
+                    }
+                }    
+            }
 	        // For automatic creation
 	        if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code);
 
@@ -2918,6 +2951,7 @@ class Product extends CommonObject
 					$this->stock_warehouse[$row->fk_entrepot] = new stdClass();
 					$this->stock_warehouse[$row->fk_entrepot]->real = $row->reel;
 					$this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp;
+					$this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid;
 					if ($this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1);
 					$this->stock_reel+=$row->reel;
 					$i++;