diff -BNaur '--exclude=CVS' '--exclude=*.patch' '--exclude=.#*' '--exclude=*~' '--exclude=*.rej' '--exclude=*.orig' '--exclude=*.bak' '--exclude=conf.php' '--exclude=documents' original/htdocs/core/class/extrafields.class.php custom/htdocs/core/class/extrafields.class.php --- original/htdocs/core/class/extrafields.class.php 2014-10-03 03:10:17.000000000 +0200 +++ custom/htdocs/core/class/extrafields.class.php 2014-12-23 15:16:35.116957800 +0100 @@ -751,7 +751,7 @@ } } if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it. - $sql.=preg_replace('/^ AND /','',$sqlwhere); + if (strlen($sqlwhere)) $sql.= ' WHERE ' . preg_replace('/^ AND /','',$sqlwhere); //print $sql; dol_syslog(get_class($this).'::showInputField type=sellist sql='.$sql);