diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 42418184c4f7d397e47aa12fc75274cf9277eb43..a4799bc53fe2b09e5ece7e28599aa0f9de6b6231 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -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) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 24506fb31a8495de7e12d2703aceb10df5ed4504..f1de6a68a7854366ee9b891e971aaac43c9139d1 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -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