Fix bug with empty code - return -1

This commit is contained in:
aspangaro 2015-12-22 07:31:59 +01:00
parent 61208537d8
commit 07b42f2bd5

View File

@ -157,6 +157,7 @@ if (empty($reshook))
} }
} }
/*
if ($action == 'setaccountancy_code_buy') { if ($action == 'setaccountancy_code_buy') {
$result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy')); $result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy'));
@ -170,6 +171,7 @@ if (empty($reshook))
if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors'); if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors');
$action=""; $action="";
} }
*/
// Add a product or service // Add a product or service
if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
@ -262,10 +264,11 @@ if (empty($reshook))
$object->finished = GETPOST('finished'); $object->finished = GETPOST('finished');
$object->fk_unit = GETPOST('units'); $object->fk_unit = GETPOST('units');
if (GETPOST('accountancy_code_sell') <= 0) { $accountancy_code_sell = ''; } else { $accountancy_code_sell = GETPOST('accountancy_code_sell'); } $accountancy_code_sell = GETPOST('accountancy_code_sell');
if (GETPOST('accountancy_code_buy') <= 0) { $accountancy_code_buy = ''; } else { $accountancy_code_buy = GETPOST('accountancy_code_buy'); } $accountancy_code_buy = GETPOST('accountancy_code_buy');
$object->accountancy_code_sell = $accountancy_code_sell;
$object->accountancy_code_buy = $accountancy_code_buy; if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; }
if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
// MultiPrix // MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES))
@ -374,10 +377,11 @@ if (empty($reshook))
$object->barcode_type_coder = $stdobject->barcode_type_coder; $object->barcode_type_coder = $stdobject->barcode_type_coder;
$object->barcode_type_label = $stdobject->barcode_type_label; $object->barcode_type_label = $stdobject->barcode_type_label;
if (GETPOST('accountancy_code_sell') <= 0) { $accountancy_code_sell = ''; } else { $accountancy_code_sell = GETPOST('accountancy_code_sell'); } $accountancy_code_sell = GETPOST('accountancy_code_sell');
if (GETPOST('accountancy_code_buy') <= 0) { $accountancy_code_buy = ''; } else { $accountancy_code_buy = GETPOST('accountancy_code_buy'); } $accountancy_code_buy = GETPOST('accountancy_code_buy');
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy'); if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; }
if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);