Merge pull request #17631 from fappels/14_reception
Fix: Add test to delete supplier order if reception exist
This commit is contained in:
commit
0121150e02
@ -2070,6 +2070,18 @@ class CommandeFournisseur extends CommonOrder
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
// Test we can delete
|
||||
$this->fetchObjectLinked(null, 'order_supplier');
|
||||
if (!empty($this->linkedObjects)) {
|
||||
foreach ($this->linkedObjects['reception'] as $element) {
|
||||
if ($element->statut >= 0) {
|
||||
$this->errors[] = $langs->trans('ReceptionExist');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$main = MAIN_DB_PREFIX.'commande_fournisseurdet';
|
||||
$ef = $main."_extrafields";
|
||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")";
|
||||
|
||||
@ -2325,7 +2325,7 @@ if ($action == 'create') {
|
||||
print dol_get_fiche_end();
|
||||
|
||||
/**
|
||||
* Boutons actions
|
||||
* Buttons for actions
|
||||
*/
|
||||
|
||||
if ($user->socid == 0 && $action != 'editline' && $action != 'delete') {
|
||||
@ -2433,11 +2433,19 @@ if ($action == 'create') {
|
||||
}
|
||||
|
||||
// Ship
|
||||
|
||||
$hasreception = 0;
|
||||
if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) {
|
||||
$labelofbutton = $langs->trans('ReceiveProducts');
|
||||
if ($conf->reception->enabled) {
|
||||
$labelofbutton = $langs->trans("CreateReception");
|
||||
if (!empty($object->linkedObjects)) {
|
||||
foreach ($object->linkedObjects['reception'] as $element) {
|
||||
if ($element->statut >= 0) {
|
||||
$hasreception = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($object->statut, array(3, 4, 5))) {
|
||||
@ -2508,7 +2516,11 @@ if ($action == 'create') {
|
||||
|
||||
// Delete
|
||||
if (!empty($usercandelete) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && !empty($usercancreate))) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a>';
|
||||
if ($hasreception) {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ReceptionExist").'">'.$langs->trans("Delete").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,4 +44,4 @@ ValidateOrderFirstBeforeReception=You must first validate the order before being
|
||||
ReceptionsNumberingModules=Numbering module for receptions
|
||||
ReceptionsReceiptModel=Document templates for receptions
|
||||
NoMorePredefinedProductToDispatch=No more predefined products to dispatch
|
||||
|
||||
ReceptionExist=A reception exists
|
||||
|
||||
Loading…
Reference in New Issue
Block a user