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

Conflicts:
	ChangeLog
	htdocs/core/class/html.formfile.class.php
	htdocs/core/lib/product.lib.php
	htdocs/filefunc.inc.php
	htdocs/product/class/product.class.php
	htdocs/product/list.php
This commit is contained in:
Laurent Destailleur 2019-11-29 11:42:08 +01:00
commit 3b9d2abcb2
5 changed files with 80 additions and 39 deletions

View File

@ -207,6 +207,29 @@ Following changes may create regressions for some external modules, but were nec
* The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core.
***** ChangeLog for 10.0.4 compared to 10.0.3 *****
FIX: The pdf templates were using the large logo making PDF too large (and edition of proposal, order, invoice VERY slow)
FIX: #12258
FIX: #12319 Restore feature ACCOUNTANCY_AUTOFILL_ACCOUNT_WITH_GENERIC.
FIX: #12356
FIX: #12372
FIX: #12385
FIX: Advisory ID: usd20190053
FIX: Advisory ID: usd20190067
FIX: Avoid fatal error when creating thumb from PDF
FIX: compatibility with Multicompany
FIX: display job of contact list
FIX: Extrafields missing in export of expense report
FIX: Hook getAccessForbiddenMessage was missing parameters
FIX: limit 20 prevent to see all products/services
FIX: Search on leave request ref
FIX: security check. A user can see holiday with link without permissions
FIX: Set unpaid of expense report
FIX: shipping extrafields line
FIX: the SELECT examine more than MAX_JOIN_SIZE rows #12305
FIX: triggers: directories read with opendir() never closed
FIX: we need to be able to recalculate tva only if invoice not in accountancy
FIX: wrong invoice id for fetchObjetctLinked
***** ChangeLog for 10.0.3 compared to 10.0.2 *****
IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card.

View File

@ -749,7 +749,7 @@ class FormFile
$defaultlang = $codelang ? $codelang : $langs->getDefaultLang();
$morecss = 'maxwidth150';
if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100';
$out .= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss);
$out .= $formadmin->select_language($defaultlang, 'lang_id', 0, null, 0, 0, 0, $morecss);
}
else
{

View File

@ -513,36 +513,46 @@ function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $
function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_short_label = 0)
{
global $langs, $db;
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$measuringUnits = new CUnits($db);
global $measuring_unit_cache;
if ($scale !== '')
if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label]))
{
$arrayforfilter = array(
't.scale' => $scale,
't.unit_type' => $measuring_style,
't.active' => 1
);
}
else
{
$arrayforfilter = array(
't.rowid' => $unit,
't.unit_type' => $measuring_style,
't.active' => 1
);
}
$result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter);
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$measuringUnits= new CUnits($db);
if ($result < 0) {
return -1;
} else {
if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
if ($use_short_label) return $measuringUnits->records[key($measuringUnits->records)]->short_label;
else return $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
} else {
return '';
if ($scale !== '')
{
$arrayforfilter = array(
't.scale' => $scale,
't.unit_type' => $measuring_style,
't.active' => 1
);
}
else
{
$arrayforfilter = array(
't.rowid' => $unit,
't.unit_type' => $measuring_style,
't.active' => 1
);
}
$result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter);
if ($result < 0) {
return -1;
} else {
if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
if ($use_short_label) $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
else $labeltoreturn = $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
} else {
$labeltoreturn = '';
}
$measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label] = $labeltoreturn;
return $labeltoreturn;
}
}
else {
return $measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label];
}
}

View File

@ -4241,7 +4241,7 @@ class Product extends CommonObject
if ($this->type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
if (! empty($conf->productbatch->enabled)) {
$langs->load("productbatch");
$langs->load("productbatch");
$label.="<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0, 2);
}
}
@ -4584,12 +4584,12 @@ class Product extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products)
* This function need a lot of load. If you use it on list, use a cache to execute it once for each product id.
* If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible.
* Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products)
* This function need a lot of load. If you use it on list, use a cache to execute it once for each product id.
* If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible.
*
* @param string $option '' = Load all stock info, also from closed and internal warehouses,
* @return int < 0 if KO, > 0 if OK
* @param string $option '' = Load all stock info, also from closed and internal warehouses, 'nobatch', 'novirtual'
* @return int < 0 if KO, > 0 if OK
* @see load_virtual_stock(), loadBatchInfo()
*/
public function load_stock($option = '')
@ -4619,7 +4619,8 @@ class Product extends CommonObject
$sql .= " WHERE w.entity IN (".getEntity('stock').")";
$sql .= " AND w.rowid = ps.fk_entrepot";
$sql .= " AND ps.fk_product = ".$this->id;
if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) { $sql .= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")";
if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) {
$sql .= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")";
}
dol_syslog(get_class($this)."::load_stock", LOG_DEBUG);
@ -4634,7 +4635,8 @@ class Product extends CommonObject
$this->stock_warehouse[$row->fk_entrepot] = new stdClass();
$this->stock_warehouse[$row->fk_entrepot]->real = $row->reel;
$this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid;
if ((!preg_match('/nobatch/', $option)) && $this->hasbatch()) { $this->stock_warehouse[$row->fk_entrepot]->detail_batch = Productbatch::findAll($this->db, $row->rowid, 1, $this->id);
if ((!preg_match('/nobatch/', $option)) && $this->hasbatch()) {
$this->stock_warehouse[$row->fk_entrepot]->detail_batch = Productbatch::findAll($this->db, $row->rowid, 1, $this->id);
}
$this->stock_reel += $row->reel;
$i++;

View File

@ -833,7 +833,7 @@ if ($resql)
$obj = $db->fetch_object($resql);
// Multilangs
if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
if (!empty($conf->global->MAIN_MULTILANGS)) // If multilang is enabled
{
$sql = "SELECT label";
$sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
@ -851,7 +851,8 @@ if ($resql)
$product_static->id = $obj->rowid;
$product_static->ref = $obj->ref;
$product_static->ref_fourn = $obj->ref_supplier;
$product_static->ref_fourn = $obj->ref_supplier; // deprecated
$product_static->ref_supplier = $obj->ref_supplier;
$product_static->label = $obj->label;
$product_static->type = $obj->fk_product_type;
$product_static->status_buy = $obj->tobuy;
@ -876,15 +877,17 @@ if ($resql)
$product_static->surface = $obj->surface;
$product_static->surface_units = $obj->surface_units;
// STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock.
if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock
{
if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service
{
$product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock()
$option = 'nobatch';
if (empty($arrayfields['stock_virtual']['checked'])) $option .= ',novirtual';
$product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock()
}
}
print '<tr class="oddeven">';
// Ref
@ -895,6 +898,7 @@ if ($resql)
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Ref supplier
if (!empty($arrayfields['pfp.ref_fourn']['checked']))
{
@ -903,6 +907,7 @@ if ($resql)
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Label
if (!empty($arrayfields['p.label']['checked']))
{
@ -1179,6 +1184,7 @@ if ($resql)
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Action
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined