From 25ea797aed961cd1bbc2df647a7ab532e18922e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Sep 2024 18:26:24 +0200 Subject: [PATCH 1/4] Fix not default template for BOM --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 68cd44dcf46..0ad0cddf96d 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -986,7 +986,7 @@ class BOM extends CommonObject $outputlangs->load("products"); if (!dol_strlen($modele)) { - $modele = 'standard'; + $modele = ''; if ($this->model_pdf) { $modele = $this->model_pdf; From f287d100a367a84c262a0f35b86c45e4cfa4cc5a Mon Sep 17 00:00:00 2001 From: atm-irvine <165771178+atm-irvine@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:49:44 +0200 Subject: [PATCH 2/4] Use <= 0 instead of ! because delete method returns -1 or 1 (#31268) * Use <= 0 instead of ! because delete method returns -1 or 1 * Added contact * Removed user from parameters --- htdocs/categories/class/api_categories.class.php | 4 ++-- htdocs/societe/class/api_contacts.class.php | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e10371f87b6..77356ba2a87 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -267,8 +267,8 @@ class Categories extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->category->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when delete category'); + if ($this->category->delete(DolibarrApiAccess::$user) <= 0) { + throw new RestException(500, 'Error when delete category : ' . $this->category->error); } return array( diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index afd6c5807a5..d8839c9a122 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -348,7 +348,7 @@ class Contacts extends DolibarrApi * Delete contact * * @param int $id Contact ID - * @return integer + * @return array[] */ public function delete($id) { @@ -364,7 +364,17 @@ class Contacts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contact->oldcopy = clone $this->contact; - return $this->contact->delete(); + + if ($this->contact->delete() <= 0) { + throw new RestException(500, 'Error when delete contact ' . $this->contact->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact deleted' + ) + ); } /** From 63f6d0aa43e0a48a356c719dee53fd11b6737899 Mon Sep 17 00:00:00 2001 From: Joachim Kueter Date: Sun, 6 Oct 2024 13:53:16 +0200 Subject: [PATCH 3/4] Fix: Number of decimals for stock values ignores configuration (#31285) * Fix: Number of decimals for stock values ignores configuration In the select filed for adding a new line for a proposal/invoice/... product as a line, the stock level is always printed with exactly two decimals. The number of decimals should be controlled by the existing global variable MAIN_MAX_DECIMALS_STOCK, but it is not taken into account: Building the stock level with the function price from the function price2num, which uses the configured number of decimals always lead to exactly two decimals. * Fixed patch according to suggestion. --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a4b050def56..aaf856152b7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3334,7 +3334,7 @@ class Form if (isModEnabled('stock') && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) { if ($user->hasRight('stock', 'lire')) { - $opt .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS')); + $opt .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS'), 0, $langs, 0, 0); if ($objp->stock > 0) { $outval .= ' - '; From 63d4b5e3d8c22f76f5e4ca46fb3fc45a8dcf771b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Oct 2024 22:17:26 +0200 Subject: [PATCH 4/4] FIX Backport fix fatal error on price with some truncating setup --- htdocs/core/lib/functions.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 785889eab78..0218301af75 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5931,9 +5931,10 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ $nbdecimal = dol_strlen($decpart); } // Si on depasse max - if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) { - $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN; - if (preg_match('/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN)) { + $max_nbdecimal = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN')); + if ($trunc && $nbdecimal > $max_nbdecimal) { + $nbdecimal = $max_nbdecimal; + if (preg_match('/\.\.\./i', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'))) { // Si un affichage est tronque, on montre des ... $end = '...'; }