Merge branch '8.0' of git@github.com:Dolibarr/dolibarr.git into 9.0

This commit is contained in:
Laurent Destailleur 2019-03-21 18:26:02 +01:00
commit 55d64d441f
2 changed files with 10 additions and 4 deletions

View File

@ -5100,7 +5100,10 @@ abstract class CommonObject
{
foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
{
$sql.=",".$tmpkey;
if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
{
$sql.=",".$tmpkey;
}
}
}
$sql .= ") VALUES (".$this->id;
@ -5126,8 +5129,11 @@ abstract class CommonObject
{
foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
{
if (in_array($tmpval, array('int', 'double'))) $sql.=", 0";
else $sql.=", ''";
if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
{
if (in_array($tmpval, array('int', 'double'))) $sql.=", 0";
else $sql.=", ''";
}
}
}

View File

@ -820,7 +820,7 @@ class ExtraFields
{
if ($tab->entity != 0 && $tab->entity != $conf->entity)
{
// This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field
// This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value
if ($tab->fieldrequired && is_null($tab->fielddefault))
{
$this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type;