From 9a05c16edc615eae9acd997294f95503c44c1b0f Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 3 Apr 2023 11:50:06 +0200 Subject: [PATCH 1/3] NEW : Stock limit for alert and desired optimal stock by product and warehouse import --- htdocs/core/modules/modProduct.class.php | 25 ++++++++++++++++++++++++ htdocs/langs/en_US/stocks.lang | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 560ca3d7277..5446fa56a57 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -620,6 +620,31 @@ class modProduct extends DolibarrModules $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled + if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { + + // Import products limit and desired stock by product and warehouse + $r++; + $this->import_code[$r] = $this->rights_class.'_stock_by_warehouse'; + $this->import_label[$r] = "ProductStockWarehouse"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('pwp'=>MAIN_DB_PREFIX.'product_warehouse_properties'); + $this->import_fields_array[$r] = array('pwp.fk_product'=>"Product*", + 'pwp.fk_entrepot'=>"Warehouse*", 'pwp.seuil_stock_alerte'=>"StockLimit", + 'pwp.desiredstock'=>"DesiredStock"); + $this->import_convertvalue_array[$r] = array( + 'pwp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') + ,'pwp.fk_entrepot'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'Entrepot') + ); + $this->import_examplevalues_array[$r] = array('pwp.fk_product'=>"ref:PRODUCT_REF or id:123456", + 'pwp.fk_entrepot'=>"ref:WAREHOUSE_REF or id:123456", + 'pwp.seuil_stock_alerte'=>"100", + 'pwp.desiredstock'=>"110" + ); + $this->import_updatekeys_array[$r] = array('pwp.fk_product'=>'Product', 'pwp.fk_entrepot'=>'Warehouse'); + + } + if (!empty($conf->fournisseur->enabled)) { // Import suppliers prices (note: this code is duplicated in module Service) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 1b54e53d6de..df0420947e3 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -173,6 +173,7 @@ OptionMULTIPRICESIsOn=Option "several prices per segment" is on. It means a prod ProductStockWarehouseCreated=Stock limit for alert and desired optimal stock correctly created ProductStockWarehouseUpdated=Stock limit for alert and desired optimal stock correctly updated ProductStockWarehouseDeleted=Stock limit for alert and desired optimal stock correctly deleted +ProductStockWarehouse=Stock limit for alert and desired optimal stock by product and warehouse AddNewProductStockWarehouse=Set new limit for alert and desired optimal stock AddStockLocationLine=Decrease quantity then click to add another warehouse for this product InventoryDate=Inventory date @@ -240,4 +241,4 @@ InventoryRealQtyHelp=Set value to 0 to reset qty
Keep field empty, or remove UpdateByScaning=Update by scaning UpdateByScaningProductBarcode=Update by scan (product barcode) UpdateByScaningLot=Update by scan (lot|serial barcode) -DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. \ No newline at end of file +DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. From 69791c8530a05095079c80814e1182644ddd7f71 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 3 Apr 2023 10:10:48 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/core/modules/modProduct.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index ec5f7c78395..771871ed563 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -748,8 +748,7 @@ class modProduct extends DolibarrModules $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled } - if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { - + if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { // Import products limit and desired stock by product and warehouse $r++; $this->import_code[$r] = $this->rights_class.'_stock_by_warehouse'; @@ -770,7 +769,6 @@ class modProduct extends DolibarrModules 'pwp.desiredstock'=>"110" ); $this->import_updatekeys_array[$r] = array('pwp.fk_product'=>'Product', 'pwp.fk_entrepot'=>'Warehouse'); - } if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { From 8364de054a1787beac72cc07c1395cdcc20db4cd Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 3 Apr 2023 14:29:46 +0200 Subject: [PATCH 3/3] FIX : regex array checks --- htdocs/core/modules/modProduct.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 5446fa56a57..eb36fd67ba8 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -632,9 +632,13 @@ class modProduct extends DolibarrModules $this->import_fields_array[$r] = array('pwp.fk_product'=>"Product*", 'pwp.fk_entrepot'=>"Warehouse*", 'pwp.seuil_stock_alerte'=>"StockLimit", 'pwp.desiredstock'=>"DesiredStock"); + $this->import_regex_array[$r] = array( + 'pwp.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', + 'pwp.fk_entrepot' => 'rowid@'.MAIN_DB_PREFIX.'entrepot', + ); $this->import_convertvalue_array[$r] = array( 'pwp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') - ,'pwp.fk_entrepot'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'Entrepot') + ,'pwp.fk_entrepot'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/stock/class/entrepot.class.php', 'class'=>'Entrepot', 'method'=>'fetch', 'element'=>'Entrepot') ); $this->import_examplevalues_array[$r] = array('pwp.fk_product'=>"ref:PRODUCT_REF or id:123456", 'pwp.fk_entrepot'=>"ref:WAREHOUSE_REF or id:123456",