Fix error management when renaming a project with existing ref.

This commit is contained in:
Laurent Destailleur 2017-03-02 20:06:10 +01:00
parent 5842d1ee41
commit e6846f5c01
2 changed files with 16 additions and 8 deletions

View File

@ -270,8 +270,9 @@ if (empty($reshook))
$result=$object->update($user); $result=$object->update($user);
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
setEventMessages($object->error, $object->errors,'errors'); if ($result == -4) setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors');
else setEventMessages($object->error, $object->errors, 'errors');
}else { }else {
// Category association // Category association
$categories = GETPOST('categories'); $categories = GETPOST('categories');

View File

@ -334,12 +334,19 @@ class Project extends CommonObject
} }
else else
{ {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
$this->db->rollback(); $this->db->rollback();
dol_syslog(get_class($this)."::update error -2 " . $this->error, LOG_ERR); if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
$result = -2; {
} $result = -4;
}
else
{
$result = -2;
}
dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR);
}
} }
else else
{ {