Merge pull request #23540 from fappels/develop_disallow_reopen_when_reception

FIX Disallow supplier order line delete if already received.
This commit is contained in:
Laurent Destailleur 2023-01-18 23:34:05 +01:00 committed by GitHub
commit 02c2a6f6d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -2141,6 +2141,16 @@ class CommandeFournisseur extends CommonOrder
return 0;
}
// check if not yet received
$dispatchedLines = $this->getDispachedLines();
foreach ($dispatchedLines as $dispatchLine) {
if ($dispatchLine['orderlineid'] == $idline) {
$this->error = "LineAlreadyDispatched";
$this->errors[] = $this->error;
return -3;
}
}
if ($line->delete($notrigger) > 0) {
$this->update_price(1);
return 1;
@ -2329,7 +2339,7 @@ class CommandeFournisseur extends CommonOrder
// List of already dispatched lines
$sql = "SELECT p.ref, p.label,";
$sql .= " e.rowid as warehouse_id, e.ref as entrepot,";
$sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status";
$sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.fk_commandefourndet";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
$sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
@ -2353,6 +2363,7 @@ class CommandeFournisseur extends CommonOrder
'productid' => $objp->fk_product,
'warehouseid' => $objp->warehouse_id,
'qty' => $objp->qty,
'orderlineid' => $objp->fk_commandefourndet
);
}

View File

@ -204,3 +204,5 @@ StatusSupplierOrderApproved=Approved
StatusSupplierOrderRefused=Refused
StatusSupplierOrderReceivedPartially=Partially received
StatusSupplierOrderReceivedAll=All products received
NeedAtLeastOneInvoice = There has to be at least one Invoice
LineAlreadyDispatched = The order line is already received.