From 49991eabf8c2b90aea1ab51306064bf806fce924 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 May 2019 17:09:18 +0200 Subject: [PATCH] Fix import of accounting account from ref in import profiles --- htdocs/core/modules/import/import_csv.modules.php | 7 +++++-- htdocs/core/modules/import/import_xlsx.modules.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 6db495e9f04..8ffab2ddbee 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -443,11 +443,14 @@ class ImportCsv extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method),array('', $newval)); + $param_array = array('', $newval); + if ($class == 'AccountingAccount') $param_array = array('', $newval, 1); + call_user_func_array(array($classinstance, $method), $param_array); // If not found, try the fetch from label if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel') { - call_user_func_array(array($classinstance, $method),array('', '', $newval)); + $param_array = array('', '', $newval); + call_user_func_array(array($classinstance, $method), $param_array); } $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index d96dc18104f..707a4f745eb 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -470,11 +470,14 @@ class ImportXlsx extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method),array('', $newval)); + $param_array = array('', $newval); + if ($class == 'AccountingAccount') $param_array = array('', $newval, 1); + call_user_func_array(array($classinstance, $method), $param_array); // If not found, try the fetch from label if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel') { - call_user_func_array(array($classinstance, $method),array('', '', $newval)); + $param_array = array('', '', $newval); + call_user_func_array(array($classinstance, $method), $param_array); } $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';