FIX : PR returns
This commit is contained in:
parent
43428f622f
commit
468f4d18cb
2 changed files with 10 additions and 4 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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).")";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue