2
0
forked from Wavyzz/dolibarr

Try to fix error on pgsql

This commit is contained in:
Laurent Destailleur
2019-03-08 20:06:09 +01:00
parent e38427a41f
commit b766031abf
2 changed files with 10 additions and 6 deletions

View File

@@ -229,7 +229,11 @@ class ExpenseReport extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (!$resql) $error++; if (!$resql)
{
$this->error = $this->db->lasterror();
$error++;
}
if (is_array($this->lines) && count($this->lines)>0) if (is_array($this->lines) && count($this->lines)>0)
{ {
@@ -238,7 +242,7 @@ class ExpenseReport extends CommonObject
$newndfline=new ExpenseReportLine($this->db); $newndfline=new ExpenseReportLine($this->db);
$newndfline=$this->lines[$i]; $newndfline=$this->lines[$i];
$newndfline->fk_expensereport=$this->id; $newndfline->fk_expensereport=$this->id;
if ($result >= 0) if (! $error)
{ {
$result=$newndfline->insert(); $result=$newndfline->insert();
} }
@@ -2560,7 +2564,7 @@ class ExpenseReportLine
*/ */
public function insert($notrigger = 0, $fromaddline = false) public function insert($notrigger = 0, $fromaddline = false)
{ {
global $langs,$user,$conf; global $langs, $user, $conf;
$error=0; $error=0;

View File

@@ -136,7 +136,7 @@ class ExpenseReportTest extends PHPUnit_Framework_TestCase
// Create supplier order with a too low quantity // Create supplier order with a too low quantity
$localobject=new ExpenseReport($db); $localobject=new ExpenseReport($db);
$localobject->initAsSpecimen(); // Init a speciment with lines $localobject->initAsSpecimen(); // Init a specimen with lines
$localobject->status = 0; $localobject->status = 0;
$localobject->fk_statut = 0; $localobject->fk_statut = 0;
$localobject->date_fin = null; // Force bad value $localobject->date_fin = null; // Force bad value
@@ -150,13 +150,13 @@ class ExpenseReportTest extends PHPUnit_Framework_TestCase
// Create supplier order // Create supplier order
$localobject2=new ExpenseReport($db); $localobject2=new ExpenseReport($db);
$localobject2->initAsSpecimen(); // Init a speciment with lines $localobject2->initAsSpecimen(); // Init a specimen with lines
$localobject2->status = 0; $localobject2->status = 0;
$localobject2->fk_statut = 0; $localobject2->fk_statut = 0;
$result=$localobject2->create($user); $result=$localobject2->create($user);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertGreaterThanOrEqual(0, $result); $this->assertGreaterThanOrEqual(0, $result, "Error: ".$localobject2->error);
return $result; return $result;
} }