diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index bde888157dd..1e4284dec7f 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -509,12 +509,12 @@ class ImportCsv extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + if ($classinstance->id != '') // id may be 0, it is a found value { - $newval=$classinstance->code; + $newval=$classinstance->id; } else { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index a67a0c90c4b..b83199e2ac6 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -536,12 +536,12 @@ class ImportXlsx extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + if ($classinstance->id != '') // id may be 0, it is a found value { - $newval=$classinstance->code; + $newval=$classinstance->id; } else { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index c71694c48ec..3d943d432a9 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -354,6 +354,7 @@ class modProduct extends DolibarrModules 'p.note_public' => "PublicNote",//public note 'p.note' => "PrivateNote",//private note 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', 'p.price' => "SellingPriceHT",//without 'p.price_min' => "MinPrice", 'p.price_ttc' => "SellingPriceTTC",//with tax @@ -441,8 +442,15 @@ class modProduct extends DolibarrModules 'method' => 'fetch', 'units' => 'volume', 'dict' => 'DictionaryMeasuringUnits' - ) - );*/ + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) + ); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); @@ -486,6 +494,7 @@ class modProduct extends DolibarrModules 'p.note_public' => "a public note (free text)", 'p.note' => "a private note (free text)", 'p.customcode' => 'customs code', + 'p.fk_country' => 'FR', 'p.price' => "price ex-vat eg. 100", 'p.price_min' => "price ex-vat eg. 100", 'p.price_ttc' => "price inc-vat eg. 110",