Skip to content
Snippets Groups Projects
Commit dbae31b9 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge branch '3.6' of git@github.com:Dolibarr/dolibarr.git into 3.6

parents e94ffcea a6a799c8
No related branches found
No related tags found
No related merge requests found
...@@ -16,3 +16,4 @@ printEatby= Eat-by: %s ...@@ -16,3 +16,4 @@ printEatby= Eat-by: %s
printSellby= Sell-by: %s printSellby= Sell-by: %s
printQty= Qty: %d printQty= Qty: %d
AddDispatchBatchLine=Add a line for Shelf Life dispatching AddDispatchBatchLine=Add a line for Shelf Life dispatching
BatchDefaultNumber= Undefined
\ No newline at end of file
...@@ -15,3 +15,5 @@ printBatch= Lot: %s ...@@ -15,3 +15,5 @@ printBatch= Lot: %s
printEatby= DLC: %s printEatby= DLC: %s
printSellby= DLUO: %s printSellby= DLUO: %s
printQty= Qté: %d printQty= Qté: %d
AddDispatchBatchLine=Ajouter une ligne de dispatch
BatchDefaultNumber= Indéfini
\ No newline at end of file
...@@ -589,6 +589,39 @@ class Product extends CommonObject ...@@ -589,6 +589,39 @@ class Product extends CommonObject
if ($result >= 0) 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 // For automatic creation
if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code); if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code);
...@@ -2918,6 +2951,7 @@ class Product extends CommonObject ...@@ -2918,6 +2951,7 @@ class Product extends CommonObject
$this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot] = new stdClass();
$this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel;
$this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp; $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); if ($this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1);
$this->stock_reel+=$row->reel; $this->stock_reel+=$row->reel;
$i++; $i++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment