Merge pull request #15760 from FHenry/fix_duplicate_customersupliercode

Fix duplicate customersupliercode
This commit is contained in:
Laurent Destailleur 2020-12-16 00:24:16 +01:00 committed by GitHub
commit 17bd362d3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -634,11 +634,20 @@ if (empty($reshook))
}
else
{
if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case
if ($result==-3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors))
{
$duplicate_code_error = true;
$object->code_client = null;
}
if ($result==-3 && in_array('ErrorSupplierCodeAlreadyUsed', $object->errors))
{
$duplicate_code_error = true;
$object->code_fournisseur = null;
$object->code_client = null;
}
if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$duplicate_code_error = true;
}
setEventMessages($object->error, $object->errors, 'errors');