Merge branch '7.0' of git@github.com:Dolibarr/dolibarr.git into 7.0

This commit is contained in:
Laurent Destailleur 2018-05-05 13:25:00 +02:00
commit 44cb60e61d
3 changed files with 7 additions and 6 deletions

View File

@ -1116,7 +1116,7 @@ class Product extends CommonObject
//If it is a parent product, then we remove the association with child products //If it is a parent product, then we remove the association with child products
$prodcomb = new ProductCombination($this->db); $prodcomb = new ProductCombination($this->db);
if ($prodcomb->deleteByFkProductParent($id) < 0) { if ($prodcomb->deleteByFkProductParent($user, $id) < 0) {
$error++; $error++;
$this->errors[] = 'Error deleting combinations'; $this->errors[] = 'Error deleting combinations';
} }

View File

@ -275,10 +275,11 @@ class ProductCombination
/** /**
* Deletes all product combinations of a parent product * Deletes all product combinations of a parent product
* *
* @param int $fk_product_parent Rowid of parent product * @param User $user Object user
* @param int $fk_product_parent Rowid of parent product
* @return int <0 KO >0 OK * @return int <0 KO >0 OK
*/ */
public function deleteByFkProductParent($fk_product_parent) public function deleteByFkProductParent($user, $fk_product_parent)
{ {
$this->db->begin(); $this->db->begin();
@ -289,11 +290,11 @@ class ProductCombination
$res = $prodstatic->fetch($prodcomb->fk_product_child); $res = $prodstatic->fetch($prodcomb->fk_product_child);
if ($res > 0) { if ($res > 0) {
$res = $prodcomb->delete(); $res = $prodcomb->delete($user);
} }
if ($res > 0 && !$prodstatic->isObjectUsed($prodstatic->id)) { if ($res > 0 && !$prodstatic->isObjectUsed($prodstatic->id)) {
$res = $prodstatic->delete(); $res = $prodstatic->delete($user);
} }
if ($res < 0) { if ($res < 0) {

View File

@ -95,7 +95,7 @@ if ($_POST) {
$delete_prev_comb_res = 1; $delete_prev_comb_res = 1;
if (!$donotremove) { if (!$donotremove) {
$delete_prev_comb_res = $combination->deleteByFkProductParent($id); $delete_prev_comb_res = $combination->deleteByFkProductParent($user, $id);
} }
//Current combinations will be deleted //Current combinations will be deleted