Browse Source

Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0

Laurent Destailleur 1 year ago
parent
commit
57eb393dad

+ 3 - 3
htdocs/core/db/pgsql.class.php

@@ -1279,9 +1279,9 @@ class DoliDBPgsql extends DoliDB
 
 
 		if (isset($field_desc['default']) && $field_desc['default'] != '') {
 		if (isset($field_desc['default']) && $field_desc['default'] != '') {
 			if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
 			if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') {
-				$sql .= " DEFAULT ".$this->escape($field_desc['default']);
-			} elseif ($field_desc['type'] != 'text') {
-				$sql .= " DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
+				$sql .= ", ALTER COLUMN ".$this->escape($field_name)." SET DEFAULT ".((float) $field_desc['default']);
+			} elseif ($field_desc['type'] != 'text') {	// Default not supported on text fields ?
+				$sql .= ", ALTER COLUMN ".$this->escape($field_name)." SET DEFAULT '".$this->escape($field_desc['default'])."'";
 			}
 			}
 		}
 		}
 
 

+ 1 - 1
htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php

@@ -243,7 +243,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
 
 
 			$object->fetch_thirdparty();
 			$object->fetch_thirdparty();
 
 
-			$dir = $conf->facture->dir_output;
+			$dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
 			$objectref = dol_sanitizeFileName($object->ref);
 			$objectref = dol_sanitizeFileName($object->ref);
 			if (!preg_match('/specimen/i', $objectref)) {
 			if (!preg_match('/specimen/i', $objectref)) {
 				$dir .= "/".$objectref;
 				$dir .= "/".$objectref;

+ 1 - 1
test/phpunit/DoliDBTest.php

@@ -160,7 +160,7 @@ class DoliDBTest extends PHPUnit\Framework\TestCase
 		print __METHOD__." result=".$result."\n";
 		print __METHOD__." result=".$result."\n";
 
 
 		// TODO Use $savtype and $savnull instead of hard coded
 		// TODO Use $savtype and $savnull instead of hard coded
-		$field_desc = array('type'=>'varchar', 'value'=>'16', 'null'=>'NOT NULL');
+		$field_desc = array('type'=>'varchar', 'value'=>'16', 'null'=>'NOT NULL', 'default'=>'aaaabbbbccccdddd');
 
 
 		$result = $db->DDLUpdateField($db->prefix().'c_paper_format', 'code', $field_desc);
 		$result = $db->DDLUpdateField($db->prefix().'c_paper_format', 'code', $field_desc);
 		$this->assertEquals(1, $result);
 		$this->assertEquals(1, $result);