From c45b191330951781f18b5fcee91fae7b5a0755f9 Mon Sep 17 00:00:00 2001 From: "atm-florian.m" Date: Mon, 1 Jul 2019 10:18:04 +0200 Subject: [PATCH 1/8] FIX: when STOCK_CALCULATE_ON_SHIPMENT_CLOSE is set, deleting a "closed" shipment now increases stock as expected --- htdocs/expedition/class/expedition.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3ab96fed1fa..dd0d4842276 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1111,7 +1111,9 @@ class Expedition extends CommonObject } // Stock control - if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) + if (! $error && $conf->stock->enabled && + (($conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) || + ($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE && $this->statut == 2))) { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); From 64d1ebf59cd6ee27117cca10fc552257d0e17ea4 Mon Sep 17 00:00:00 2001 From: "atm-florian.m" Date: Thu, 4 Jul 2019 15:06:39 +0200 Subject: [PATCH 2/8] FIX: on shipment delete confirm dialog, a new checkbox allows the user to choose if they want their stock re-incremented after the deletion. --- htdocs/expedition/card.php | 24 ++++++++++++++++++-- htdocs/expedition/class/expedition.class.php | 4 ++-- htdocs/langs/fr_FR/sendings.lang | 2 ++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index aa85132b243..ed6b0227f91 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -468,7 +468,8 @@ if (empty($reshook)) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) { - $result = $object->delete(); + $also_update_stock = GETPOST('alsoUpdateStock', 'alpha') ?: 0; + $result = $object->delete($also_update_stock); if ($result > 0) { header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); @@ -1648,7 +1649,26 @@ else if ($id || $ref) // Confirm deleteion if ($action == 'delete') { - $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$object->ref),'confirm_delete','',0,1); + $formquestion = array(); + if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $formquestion = array( + array( + 'label' => $langs->trans('ShipmentIncrementStockOnDelete'), + 'name' => 'alsoUpdateStock', + 'type' => 'checkbox', + 'value' => 0 + ), + ); + } + $formconfirm=$form->formconfirm( + $_SERVER['PHP_SELF'].'?id='.$object->id, + $langs->trans('DeleteSending'), + $langs->trans("ConfirmDeleteSending",$object->ref), + 'confirm_delete', + $formquestion, + 0, + 1 + ); } // Confirmation validation diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3ab96fed1fa..814d8ccc5a1 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1079,7 +1079,7 @@ class Expedition extends CommonObject * * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ - function delete() + function delete($also_update_stock = false) { global $conf, $langs, $user; @@ -1111,7 +1111,7 @@ class Expedition extends CommonObject } // Stock control - if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) + if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT && $also_update_stock) { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 1071d5f23f9..4f4bfc514e2 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -60,6 +60,8 @@ NoProductToShipFoundIntoStock=Aucun produit à expédier n'a été trouver dans WeightVolShort=Poids/vol. ValidateOrderFirstBeforeShipment=Vous devez d'abord valider la commande pour pouvoir créer une expédition. +ShipmentIncrementStockOnDelete=Remettre en stock les éléments de cette expédition + # Sending methods # ModelDocument DocumentModelTyphon=Modèle de bon de réception/livraison complet (logo…) From cce8f98afc7638becb92e2a4e9344c7de40c2b21 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 10 Jul 2019 16:33:03 +0200 Subject: [PATCH 3/8] FIX : accounting mode must be taken from global conf, because there's no way to choose a mode with interface --- htdocs/compta/stats/byratecountry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 2c43db42d13..cd41649cc89 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. // Load translation files required by the page $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy")); -$modecompta = GETPOST('modecompta','alpha'); +$modecompta = $conf->global->ACCOUNTING_MODE; // Date range $year=GETPOST("year",'int'); From abd0abf11531b196fe07e8bac545ea95071b95ef Mon Sep 17 00:00:00 2001 From: Nicolas ZABOURI Date: Wed, 10 Jul 2019 18:36:12 +0200 Subject: [PATCH 4/8] FIX element name in update_price --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f0fe7bf437c..43f78b571de 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Bahfir abbes * Copyright (C) 2017 ATM Consulting - * Copyright (C) 2017 Nicolas ZABOURI + * Copyright (C) 2017-2019 Nicolas ZABOURI * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018 Frederic France * @@ -2615,7 +2615,7 @@ abstract class CommonObject $MODULE = ""; if ($this->element == 'propal') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; - elseif ($this->element == 'order') + elseif ($this->element == 'commande') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; elseif ($this->element == 'facture') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; From 4f0316580672122e1154c148935d5e17264ad433 Mon Sep 17 00:00:00 2001 From: "atm-florian.m" Date: Thu, 11 Jul 2019 12:28:24 +0200 Subject: [PATCH 5/8] FIX: outdated phpdoc --- htdocs/expedition/class/expedition.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index a8d9acc7b48..ea6e003d326 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1073,12 +1073,14 @@ class Expedition extends CommonObject } } - /** - * Delete shipment. - * Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element) - * - * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO - */ + /** + * Delete shipment. + * Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element) + * + * @param bool $also_update_stock true if the stock should be increased back (false by default) + * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO + * @throws Exception + */ function delete($also_update_stock = false) { global $conf, $langs, $user; From f041110a7ef88cd8057d515bce96946c0242bf3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Jul 2019 22:29:50 +0200 Subject: [PATCH 6/8] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 43f78b571de..579deec88e3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2615,7 +2615,7 @@ abstract class CommonObject $MODULE = ""; if ($this->element == 'propal') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; - elseif ($this->element == 'commande') + elseif ($this->element == 'commande' || $this->element == 'order') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; elseif ($this->element == 'facture') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; From b6571d9fc3a27f147ace6d6794f6d58a9690a749 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Jul 2019 22:39:25 +0200 Subject: [PATCH 7/8] Update byratecountry.php --- htdocs/compta/stats/byratecountry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index cd41649cc89..045f5e6429c 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. // Load translation files required by the page $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy")); -$modecompta = $conf->global->ACCOUNTING_MODE; +$modecompta = (GETPOST('modecompta', 'alpha') ? GETPOST('modecompta', 'alpha') : $conf->global->ACCOUNTING_MODE); // Date range $year=GETPOST("year",'int'); From c72a59ad36641ab13dbe382c8d52fb36d68b0461 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 16 Jul 2019 14:55:19 +0200 Subject: [PATCH 8/8] FIX : we need to be able to add freeline with qty between 0 & 1 in supplierorder line --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9198cf3ac22..f32d9d24c01 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1485,7 +1485,7 @@ class CommandeFournisseur extends CommonOrder $desc=trim($desc); // Check parameters - if ($qty < 1 && ! $fk_product) + if ($qty < 0 && ! $fk_product) { $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Product")); return -1;