Merge pull request #5022 from marcosgdf/bug-5008
FIX #5008 SQL error when editing the reference of a supplier invoice that already exists
This commit is contained in:
commit
8a4871323d
@ -7,7 +7,7 @@
|
||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -646,7 +646,16 @@ class FactureFournisseur extends CommonInvoice
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
|
||||
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$this->errors[] = $langs->trans('ErrorRefAlreadyExists');
|
||||
} else {
|
||||
$this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
@ -238,8 +238,11 @@ if (empty($reshook))
|
||||
// Set supplier ref
|
||||
if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha'));
|
||||
if ($result < 0) dol_print_error($db, $object->error);
|
||||
$object->ref_supplier = GETPOST('ref_supplier', 'alpha');
|
||||
|
||||
if ($object->update() < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// conditions de reglement
|
||||
|
||||
Loading…
Reference in New Issue
Block a user