forked from Wavyzz/dolibarr
Fix: Combo list of warehouse not saved.
Fix: Validate of shipment in error when using not predefined products.
This commit is contained in:
@@ -2118,12 +2118,12 @@ else
|
||||
// Create bill and Classify billed
|
||||
if ($conf->facture->enabled && $object->statut > 0 && ! $object->billed)
|
||||
{
|
||||
if ($user->rights->facture->creer)
|
||||
if ($user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER))
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->commande->creer && $object->statut > 2)
|
||||
if ($user->rights->commande->creer && $object->statut > 2 && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
|
||||
}
|
||||
|
||||
@@ -122,7 +122,8 @@ if ($action == 'add')
|
||||
{
|
||||
$ent = "entl".$i;
|
||||
$idl = "idl".$i;
|
||||
$entrepot_id = GETPOST($ent,'int')?GETPOST($ent,'int'):GETPOST('entrepot_id','int');
|
||||
$entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int');
|
||||
if ($entrepot_id < 0) $entrepot_id='';
|
||||
|
||||
$ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int'));
|
||||
if ($ret < 0)
|
||||
@@ -779,21 +780,19 @@ if ($action == 'create')
|
||||
print '<td align="left">';
|
||||
if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
// Show warehous
|
||||
if (GETPOST('entrepot_id','int'))
|
||||
// Show warehouse combo list
|
||||
$ent = "entl".$indiceAsked;
|
||||
$idl = "idl".$indiceAsked;
|
||||
$tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int');
|
||||
print $formproduct->selectWarehouses($tmpentrepot_id,'entl'.$indiceAsked,'',1,0,$line->fk_product);
|
||||
if ($tmpentrepot_id && $tmpentrepot_id == GETPOST('entrepot_id','int'))
|
||||
{
|
||||
print $formproduct->selectWarehouses(GETPOST('entrepot_id','int'),'entl'.$indiceAsked,'',1,0,$line->fk_product);
|
||||
//print $stock.' '.$quantityToBeDelivered;
|
||||
//if ($stock >= 0 && $stock < $quantityToBeDelivered)
|
||||
if ($stock < $quantityToBeDelivered)
|
||||
{
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for entrepot_id but we may have change warehouse
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ class FormProduct
|
||||
$this->loadWarehouses($fk_product);
|
||||
|
||||
$out='<select class="flat"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.($htmlname.($disabled?'_disabled':'')).'">';
|
||||
if ($empty) $out.='<option value=""> </option>';
|
||||
if ($empty) $out.='<option value="-1"> </option>';
|
||||
foreach($this->cache_warehouses as $id => $arraytypes)
|
||||
{
|
||||
$out.='<option value="'.$id.'"';
|
||||
|
||||
@@ -1042,7 +1042,7 @@ class Product extends CommonObject
|
||||
// Check parameters
|
||||
if (! $id && ! $ref && ! $ref_ext)
|
||||
{
|
||||
$this->error=$langs->trans('ErrorWrongParameters');
|
||||
$this->error='ErrorWrongParameters';
|
||||
dol_print_error(get_class($this)."::fetch ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class MouvementStock
|
||||
* @param int $price Unit price HT of product
|
||||
* @param string $label Label of stock movement
|
||||
* @param string $datem Force date of movement
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @return int <0 if KO, 0 if fk_product is null, >0 if OK
|
||||
*/
|
||||
function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $datem='')
|
||||
{
|
||||
@@ -65,13 +65,15 @@ class MouvementStock
|
||||
$error = 0;
|
||||
dol_syslog("MouvementStock::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price label=$label");
|
||||
|
||||
if (empty($fk_product)) return 0;
|
||||
|
||||
$now=(! empty($datem) ? $datem : dol_now());
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$product = new Product($this->db);
|
||||
$result=$product->fetch($fk_product);
|
||||
if (! $result > 0)
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error('',"Failed to fetch product");
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user