Merge pull request #5301 from atm-ph/fix_develop_issue_2858
NEW issue 2858 - Option to allow negative transfer
This commit is contained in:
commit
7263b29cb4
@ -49,6 +49,10 @@ if($action)
|
|||||||
{
|
{
|
||||||
$res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
|
$res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
|
||||||
}
|
}
|
||||||
|
if ($action == 'STOCK_ALLOW_NEGATIVE_TRANSFER')
|
||||||
|
{
|
||||||
|
$res = dolibarr_set_const($db, "STOCK_ALLOW_NEGATIVE_TRANSFER", GETPOST('STOCK_ALLOW_NEGATIVE_TRANSFER','alpha'),'chaine',0,'',$conf->entity);
|
||||||
|
}
|
||||||
// Mode of stock decrease
|
// Mode of stock decrease
|
||||||
if ($action == 'STOCK_CALCULATE_ON_BILL'
|
if ($action == 'STOCK_CALCULATE_ON_BILL'
|
||||||
|| $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
|
|| $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER'
|
||||||
@ -427,6 +431,22 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
|
|||||||
print '</form>';
|
print '</form>';
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
print '<td width="60%">'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
|
||||||
|
|
||||||
|
print '<td width="160" align="right">';
|
||||||
|
print "<form method=\"post\" action=\"stock.php\">";
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_ALLOW_NEGATIVE_TRANSFER\">";
|
||||||
|
print $form->selectyesno("STOCK_ALLOW_NEGATIVE_TRANSFER",$conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER,1);
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</form>';
|
||||||
|
print "</td>\n";
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
/* I keep the option/feature, but hidden to end users for the moment. If feature is used by module, no need to have users see it.
|
/* I keep the option/feature, but hidden to end users for the moment. If feature is used by module, no need to have users see it.
|
||||||
|
|||||||
@ -71,7 +71,9 @@ class modStock extends DolibarrModules
|
|||||||
$this->langfiles = array("stocks");
|
$this->langfiles = array("stocks");
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
$this->const = array();
|
$this->const = array(
|
||||||
|
0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1)
|
||||||
|
);
|
||||||
|
|
||||||
// Boxes
|
// Boxes
|
||||||
$this->boxes = array();
|
$this->boxes = array();
|
||||||
|
|||||||
@ -120,6 +120,8 @@ StockMustBeEnoughForShipment= Stock level must be enough to add product/service
|
|||||||
MovementLabel=Label of movement
|
MovementLabel=Label of movement
|
||||||
InventoryCode=Movement or inventory code
|
InventoryCode=Movement or inventory code
|
||||||
IsInPackage=Contained into package
|
IsInPackage=Contained into package
|
||||||
|
WarehouseAllowNegativeTransfer=Allow transfer even without stock
|
||||||
|
qtyToTranferIsNotEnough=You don't have enough stock from your source warehouse
|
||||||
ShowWarehouse=Show warehouse
|
ShowWarehouse=Show warehouse
|
||||||
MovementCorrectStock=Stock correction for product %s
|
MovementCorrectStock=Stock correction for product %s
|
||||||
MovementTransferStock=Stock transfer of product %s into another warehouse
|
MovementTransferStock=Stock transfer of product %s into another warehouse
|
||||||
|
|||||||
@ -239,7 +239,7 @@ class MouvementStock extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Check qty is ok for stock move.
|
// TODO Check qty is ok for stock move.
|
||||||
if (! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
|
if (! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
|
||||||
{
|
{
|
||||||
@ -249,6 +249,17 @@ class MouvementStock extends CommonObject
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER) && in_array($type, array(1, 2)))
|
||||||
|
{
|
||||||
|
if (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty))
|
||||||
|
{
|
||||||
|
$this->error = $langs->trans('qtyToTranferIsNotEnough');
|
||||||
|
$this->errors[] = $langs->trans('qtyToTranferIsNotEnough');
|
||||||
|
$this->db->rollback();
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Define if we must make the stock change (If product type is a service or if stock is used also for services)
|
// Define if we must make the stock change (If product type is a service or if stock is used also for services)
|
||||||
$movestock=0;
|
$movestock=0;
|
||||||
|
|||||||
@ -233,7 +233,7 @@ if ($action == "transfert_stock" && ! $cancel)
|
|||||||
$pricesrc=0;
|
$pricesrc=0;
|
||||||
if (isset($object->pmp)) $pricesrc=$object->pmp;
|
if (isset($object->pmp)) $pricesrc=$object->pmp;
|
||||||
$pricedest=$pricesrc;
|
$pricedest=$pricesrc;
|
||||||
|
|
||||||
if ($object->hasbatch())
|
if ($object->hasbatch())
|
||||||
{
|
{
|
||||||
$pdluo = new Productbatch($db);
|
$pdluo = new Productbatch($db);
|
||||||
@ -324,6 +324,8 @@ if ($action == "transfert_stock" && ! $cancel)
|
|||||||
if ($result2 < 0) $error++;
|
if ($result2 < 0) $error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! $error && $result1 >= 0 && $result2 >= 0)
|
if (! $error && $result1 >= 0 && $result2 >= 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user