diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 80015e1725a..55ac48b214a 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1870,6 +1870,8 @@ class Form
$outlabel=$objp->label;
$outdesc=$objp->description;
$outtype=$objp->fk_product_type;
+ $outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration,0,dol_strlen($objp->duration)-1):'';
+ $outdurationunit=$outtype == Product::TYPE_SERVICE?substr($objp->duration,-1):'';
$opt = '\n";
- $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>$outprice_ht, 'price_ttc'=>$outprice_ttc, 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount);
+ $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>$outprice_ht, 'price_ttc'=>$outprice_ttc, 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit);
}
/**
@@ -2087,7 +2084,7 @@ class Form
$langs->load('stocks');
- $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
+ $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, p.fk_product_type,";
$sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
$sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
@@ -2145,6 +2142,9 @@ class Form
$outval='';
$outqty=1;
$outdiscount=0;
+ $outtype=$objp->fk_product_type;
+ $outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration,0,dol_strlen($objp->duration)-1):'';
+ $outdurationunit=$outtype == Product::TYPE_SERVICE?substr($objp->duration,-1):'';
$opt = '