Add test to fetch lines

This commit is contained in:
Laurent Destailleur 2022-07-14 10:15:03 +02:00
parent bec9181d3f
commit 5a7652fd75

View File

@ -668,7 +668,7 @@ class Contrat extends CommonObject
if (!$id) { if (!$id) {
$sql .= " WHERE entity IN (".getEntity('contract').")"; $sql .= " WHERE entity IN (".getEntity('contract').")";
} else { } else {
$sql .= " WHERE rowid=".(int) $id; $sql .= " WHERE rowid = ".(int) $id;
} }
if ($ref_customer) { if ($ref_customer) {
$sql .= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; $sql .= " AND ref_customer = '".$this->db->escape($ref_customer)."'";
@ -677,7 +677,7 @@ class Contrat extends CommonObject
$sql .= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; $sql .= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'";
} }
if ($ref) { if ($ref) {
$sql .= " AND ref='".$this->db->escape($ref)."'"; $sql .= " AND ref = '".$this->db->escape($ref)."'";
} }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@ -724,10 +724,13 @@ class Contrat extends CommonObject
// Retrieve all extrafields // Retrieve all extrafields
// fetch optionals attributes and labels // fetch optionals attributes and labels
$this->fetch_optionals(); $result = $this->fetch_optionals();
// Lines // Lines
$result = $this->fetch_lines(); if ($result >= 0 && !empty($this->table_element_line)) {
$result = $this->fetch_lines();
}
if ($result < 0) { if ($result < 0) {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return -3; return -3;