2
0
forked from Wavyzz/dolibarr

Fix several trouble with some types in modulebuilder

Fix difference between null and 0
This commit is contained in:
Laurent Destailleur
2019-11-17 17:36:36 +01:00
parent 502626156e
commit 16d67a1a8e
7 changed files with 105 additions and 41 deletions

View File

@@ -63,8 +63,8 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (! preg_match('/^(integer|price|sellist|date|varchar|double|text|html)/', $addfieldentry['type'])
&& ! preg_match('/^(boolean|real|timestamp)$/', $addfieldentry['type']))
if (! preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
&& ! preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
{
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2;
@@ -164,7 +164,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
if (count($object->fields))
{
$typetotypephp=array('integer'=>'integer', 'varchar'=>'string');
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
foreach($object->fields as $key => $val)
{
@@ -266,7 +266,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
elseif ($type == 'link' || $type == 'sellist') $type = 'integer';
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
$texttoinsert.= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';