Fix API to delete purchase price

This commit is contained in:
Laurent Destailleur 2020-05-02 03:33:33 +02:00
parent 4606b9fd9f
commit 90bbb9beac

View File

@ -716,18 +716,18 @@ class Products extends DolibarrApi
if (!DolibarrApiAccess::$user->rights->produit->supprimer) { if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->product->fetch($id); $result = $this->productsupplier->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Product not found'); throw new RestException(404, 'Product not found');
} }
if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) { if (!DolibarrApi::_checkAccessToResource('product', $this->productsupplier->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$resultsupplier = 0; $resultsupplier = 0;
if ($result) { if ($result > 0) {
$this->productsupplier->fetch($id); $resultsupplier = $this->productsupplier->remove_product_fournisseur_price($priceid);
$resultsupplier = $this->product->remove_product_fournisseur_price($priceid);
} }
return $resultsupplier; return $resultsupplier;