From 468f4d18cb3634d7ee2b3cf266e86b6b6836bd29 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 7 Apr 2022 17:43:40 +0200 Subject: [PATCH] FIX : PR returns --- htdocs/core/actions_addupdatedelete.inc.php | 9 ++++++++- htdocs/product/inventory/class/inventory.class.php | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index f97d4aa94ee..8b0f07c3274 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -366,7 +366,14 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto // Action validate object if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { - $result = $object->validate($user); + if($object->element == 'inventory'){ + //Case of the conf INVENTORY_INCLUDE_SUB_WAREHOUSE + $include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0; + $result = $object->validate($user, $include_sub_warehouse); + } else { + $result = $object->validate($user); + } + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 8f79a6d8267..ddb41813eae 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -257,14 +257,13 @@ class Inventory extends CommonObject * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, Id of created object if OK */ - public function validate(User $user, $notrigger = false) + public function validate(User $user, $include_sub_warehouse, $notrigger = false) { global $conf; $this->db->begin(); $result = 0; - $this->include_sub_warehouse = GETPOST('include_sub_warehouse'); if ($this->status == self::STATUS_DRAFT) { // Delete inventory $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id); @@ -291,7 +290,7 @@ class Inventory extends CommonObject } if ($this->fk_warehouse > 0) { $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse); - if (!empty($this->include_sub_warehouse) && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { + if (!empty($include_sub_warehouse) && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); $sql .= " OR ps.fk_entrepot IN (".filter_var(implode(',', $TChildWarehouses), FILTER_SANITIZE_STRING).")"; }