2
0
forked from Wavyzz/dolibarr

Merge pull request #1481 from atm-maxime/mko672

Add : Stock can be mandatory to use a product
This commit is contained in:
Laurent Destailleur
2014-03-15 17:29:31 +01:00
5 changed files with 111 additions and 4 deletions

View File

@@ -1038,7 +1038,7 @@ class Commande extends CommonOrder
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0)
{
global $mysoc;
global $mysoc, $conf, $langs;
$commandeid=$this->id;
@@ -1103,6 +1103,20 @@ class Commande extends CommonOrder
$rangmax = $this->line_max($fk_parent_line);
$rangtouse = $rangmax + 1;
}
$product_type=$type;
if (!empty($fk_product))
{
$product=new Product($this->db);
$result=$product->fetch($fk_product);
$product_type=$product->type;
if($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER && $product_type == 0 && $product->stock_reel < $qty) {
$this->error=$langs->trans('ErrorStockIsNotEnough');
$this->db->rollback();
return -3;
}
}
// TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
@@ -1127,6 +1141,7 @@ class Commande extends CommonOrder
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->fk_product=$fk_product;
$this->line->product_type=$product_type;
$this->line->fk_remise_except=$fk_remise_except;
$this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht;