FIX wrong result check when update expensereport line

This commit is contained in:
Regis Houssin 2022-09-23 09:56:54 +02:00
parent 1d87f7f2b7
commit 724490b94d

View File

@ -2069,6 +2069,7 @@ class ExpenseReport extends CommonObject
if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED) { if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED) {
$this->db->begin(); $this->db->begin();
$error = 0;
$type = 0; // TODO What if type is service ? $type = 0; // TODO What if type is service ?
// We don't know seller and buyer for expense reports // We don't know seller and buyer for expense reports
@ -2152,10 +2153,13 @@ class ExpenseReport extends CommonObject
$this->applyOffset(); $this->applyOffset();
$this->checkRules(); $this->checkRules();
$error = 0;
$result = $this->line->update($user);
if ($result > 0 && !$notrigger) { $result = $this->line->update($user);
if ($result < 0) {
$error++;
}
if (!$error && !$notrigger) {
// Call triggers // Call triggers
$result = $this->call_trigger('EXPENSE_REPORT_DET_MODIFY', $user); $result = $this->call_trigger('EXPENSE_REPORT_DET_MODIFY', $user);
if ($result < 0) { if ($result < 0) {
@ -2164,7 +2168,7 @@ class ExpenseReport extends CommonObject
// End call triggers // End call triggers
} }
if ($result > 0 && $error == 0) { if (!$error) {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {