From 30ef5f54ddf65bd66236fe8c6e83012f24a1dbd0 Mon Sep 17 00:00:00 2001 From: DEMAREST Maxime Date: Sat, 4 Jan 2020 13:55:46 +0100 Subject: [PATCH] Allow custom module class origine type in Mouvementstock --- htdocs/product/stock/class/mouvementstock.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 64871b12d17..aab0d428191 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -376,8 +376,8 @@ class MouvementStock extends CommonObject if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after { $fk_project = 0; - if (!empty($this->origin)) { // This is set by caller for tracking reason - $origintype = $this->origin->element; + if(!empty($this->origin)) { // This is set by caller for tracking reason + $origintype = empty($this->origin->origin_type)?$this->origin->element:$this->origin->origin_type; $fk_origin = $this->origin->id; if ($origintype == 'project') $fk_project = $fk_origin; else @@ -981,10 +981,14 @@ class MouvementStock extends CommonObject default: if ($origintype) { - $result = dol_include_once('/'.$origintype.'/class/'.$origintype.'.class.php'); + // Separate originetype with "@" : left part is class name, right part is module name + $origintype_array = explode('@', $origintype); + $classname = ucfirst($origintype_array[0]); + $modulename = empty($origintype_array[1]) ? $classname : empty($origintype_array[1]); + $result=dol_include_once('/'.$modulename.'/class/'.strtolower($classname).'.class.php'); if ($result) { - $classname = ucfirst($origintype); + $classname = ucfirst($classname); $origin = new $classname($this->db); } }