Merge pull request #10376 from atm-maxime/fix_extrafields_computed

Compute value of computed extrafield on fetch, not on show
This commit is contained in:
Laurent Destailleur 2019-01-21 23:41:06 +01:00 committed by GitHub
commit eba8a8f34d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -4901,6 +4901,14 @@ abstract class CommonObject
//var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]);
}
}
// If field is a computed field, value must become result of compute
foreach ($tab as $key => $value) {
if (! empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key]))
{
$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0);
}
}
}
$this->db->free($resql);

View File

@ -1547,14 +1547,6 @@ class ExtraFields
if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method.
// If field is a computed field, value must become result of compute
if ($computed)
{
// Make the eval of compute string
//var_dump($computed);
$value = dol_eval($computed, 1, 0);
}
$showsize=0;
if ($type == 'date')
{