From 90bbb9beac979a5b9d9f6957a9ef49412b7430bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 May 2020 03:33:33 +0200 Subject: [PATCH] Fix API to delete purchase price --- htdocs/product/class/api_products.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 91162d727c3..b04560dab32 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -716,18 +716,18 @@ class Products extends DolibarrApi if (!DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); } - $result = $this->product->fetch($id); + $result = $this->productsupplier->fetch($id); if (!$result) { 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); } + $resultsupplier = 0; - if ($result) { - $this->productsupplier->fetch($id); - $resultsupplier = $this->product->remove_product_fournisseur_price($priceid); + if ($result > 0) { + $resultsupplier = $this->productsupplier->remove_product_fournisseur_price($priceid); } return $resultsupplier;