Merge pull request #8951 from fappels/7.0_fix_ErrorProductAlreadyExists

Fix Wrong error for duplicate ref if barcode enabled but not set.
This commit is contained in:
Laurent Destailleur 2018-06-13 20:19:55 +02:00 committed by GitHub
commit 76ee88f0b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1000,7 +1000,7 @@ class Product extends CommonObject
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
if (empty($conf->barcode->enabled)) $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
if (empty($conf->barcode->enabled) || empty($this->barcode)) $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
else $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductBarCodeAlreadyExists",$this->barcode);
$this->errors[]=$this->error;
$this->db->rollback();