Fix regression

This commit is contained in:
Laurent Destailleur
2023-12-27 13:09:25 +01:00
parent e2c0a76c11
commit 61c5c6f88d
3 changed files with 28 additions and 1 deletions

View File

@@ -12148,7 +12148,17 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '')
$element_prop = getElementProperties($element_type);
if (is_array($element_prop) && isModEnabled($element_prop['module'])) {
if ($element_prop['module'] == 'product' || $element_prop['module'] == 'service') {
// For example, for an extrafield 'product' (shared for both product and service) that is a link to an object,
// this is called with $element_type = 'product' when we need element properties of a service, we must return a product. If we create the
// extrafield for a service, it is not supported and not found when editing the product/service card. So we must keep 'product' for extrafields
// of service and we will return properties of a product.
$ismodenabled = (isModEnabled('product') || isModEnabled('service'));
} else {
$ismodenabled = isModEnabled($element_prop['module']);
}
if (is_array($element_prop) && $ismodenabled) {
dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');
if (class_exists($element_prop['classname'])) {