2
0
forked from Wavyzz/dolibarr

Fix regression in export

This commit is contained in:
Laurent Destailleur
2021-03-30 17:28:58 +02:00
parent 22af7a0d10
commit 9ad3ba1572
3 changed files with 70 additions and 28 deletions

View File

@@ -143,7 +143,7 @@ class modService extends DolibarrModules
//--------
$r = 0;
$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p";
$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pac";
$r++;
$this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found)
@@ -368,8 +368,8 @@ class modService extends DolibarrModules
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));
$this->export_TypeFields_array[$r] = array(
'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text",
$alias_product_accounting . 'p.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text",
$alias_product_accounting . 'p.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text",
$alias_product_accounting . '.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text",
$alias_product_accounting . '.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text",
'p.note'=>"Text", 'p.note_public'=>"Text",
'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',
'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",
@@ -406,8 +406,8 @@ class modService extends DolibarrModules
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) {
$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_accounting as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity);
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity);
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';
$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';
@@ -450,13 +450,13 @@ class modService extends DolibarrModules
'p.weight' => "Weight",
'p.weight_units' => "WeightUnits",
'p.length' => "Length",
'p.length_units' => "LengthUnit",
'p.length_units' => "LengthUnits",
'p.width' => "Width",
'p.width_units' => "WidthUnits",
'p.height' => "Height",
'p.height_units' => "HeightUnit",
'p.height_units' => "HeightUnits",
'p.surface' => "Surface",
'p.surface_units' => "SurfaceUnit",
'p.surface_units' => "SurfaceUnits",
'p.volume' => "Volume",
'p.volume_units' => "VolumeUnits",
'p.duration' => "Duration", //duration of service
@@ -470,13 +470,6 @@ class modService extends DolibarrModules
'p.datec' => 'DateCreation',
'p.cost_price' => "CostPrice",
);
if (!empty($conf->stock->enabled)) {//if Stock module enabled
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning
'p.pmp' => 'PMPValue', //weighted average price
'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
));
}
$this->import_convertvalue_array[$r] = array(
'p.weight_units' => array(
@@ -535,6 +528,41 @@ class modService extends DolibarrModules
'dict' => 'DictionaryCountry'
)
);
$this->import_regex_array[$r] = array(
'p.ref' => '[^ ]',
'p.price_base_type' => '\AHT\z|\ATTC\z',
'p.tosell' => '^[0|1]$',
'p.tobuy' => '^[0|1]$',
'p.fk_product_type' => '^[0|1]$',
'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
'p.recuperableonly' => '^[0|1]$',
);
if (!empty($conf->stock->enabled)) {//if Stock module enabled
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.fk_default_warehouse'=>'DefaultWarehouse',
'p.tobatch'=>'ManageLotSerial',
'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning
'p.pmp' => 'PMPValue', //weighted average price
'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
));
$this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
'p.tobatch' => '^[0|1|2]$'
));
$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
'p.fk_default_warehouse' => array(
'rule' => 'fetchidfromref',
'classfile' => '/product/stock/class/entrepot.class.php',
'class' => 'Entrepot',
'method' => 'fetch',
'element'=> 'Warehouse'
)
));
}
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'));
}
@@ -569,7 +597,7 @@ class modService extends DolibarrModules
$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_regex_array[$r] = array(
'p.ref'=>'[^ ]',
'p.price_base_type' => '\AHT\z|\ATTC\z',
'p.price_base_type' => 'HT|TTC',
'p.tosell'=>'^[0|1]$',
'p.tobuy'=>'^[0|1]$',
'p.fk_product_type'=>'^[0|1]$',
@@ -579,7 +607,7 @@ class modService extends DolibarrModules
);
// field order as per structure of table llx_product
$import_sample = array(
'p.ref' => "PREF123456",
'p.ref' => "ref:PREF123456",
'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),
'p.label' => "Product name in default language",
'p.description' => "Product description in default language",
@@ -616,7 +644,7 @@ class modService extends DolibarrModules
'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.volume' => "",
'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units',
'p.finished' => '0 (raw material) / 1 (finished goods)'
'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"'
);
//clauses copied from import_fields_array
if (!empty($conf->stock->enabled)) {
@@ -718,7 +746,7 @@ class modService extends DolibarrModules
'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
);
$this->import_examplevalues_array[$r] = array(
'sp.fk_product' => "PRODUCT_REF or id:123456",
'sp.fk_product' => "ref:PRODUCT_REF or id:123456",
'sp.fk_soc' => "My Supplier",
'sp.ref_fourn' => "XYZ-F123456",
'sp.quantity' => "5",
@@ -755,8 +783,13 @@ class modService extends DolibarrModules
'sp.multicurrency_price'=>''
));
}
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.packagning'=>'1',
));
}
$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');
$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');
}
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
@@ -783,7 +816,7 @@ class modService extends DolibarrModules
$this->import_convertvalue_array[$r] = array(
'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
);
$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"SERVICE_REF or id:123456",
$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"ref:SERVICE_REF or id:123456",
'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1",
'pr.price'=>"100", 'pr.price_ttc'=>"110",
'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110",
@@ -806,7 +839,7 @@ class modService extends DolibarrModules
$this->import_convertvalue_array[$r] = array(
'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
);
$this->import_examplevalues_array[$r] = array('l.fk_product'=>'SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');
$this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');
$this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language');
}
}