From 50afc9682b5f460a9666d899d6a82b129d4506d6 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Mon, 6 Oct 2025 13:56:50 +0200 Subject: [PATCH 1/2] FIX create invoice from order using API and multi-entity (#35654) * FIX create invoice from order using API and multi-entity * FIX API not allow to access order in other entity on creating invoice from order * Update api_invoices.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/compta/facture/class/api_invoices.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3dfa5f70603..95a234d4991 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -315,6 +315,7 @@ class Invoices extends DolibarrApi * @return int * @throws RestException 400 * @throws RestException 401 + * @throws RestException 403 Access not allowed for login * @throws RestException 404 * @throws RestException 405 */ @@ -332,6 +333,9 @@ class Invoices extends DolibarrApi if (empty($orderid)) { throw new RestException(400, 'Order ID is mandatory'); } + if (!DolibarrApi::_checkAccessToResource('commande', $orderid)) { + throw new RestException(403, 'Access not allowed on order for login '.DolibarrApiAccess::$user->login); + } $order = new Commande($this->db); $result = $order->fetch($orderid); From 5de1fcca2f936c7d53fcd451be91081a5ced545d Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Fri, 17 Oct 2025 15:48:40 +0200 Subject: [PATCH 2/2] FIX extra-field list depend on parent extra-filed list on direct edit (#35803) --- htdocs/core/js/lib_head.js.php | 35 ++++++++++++++++++++++++ htdocs/core/tpl/extrafields_view.tpl.php | 26 +----------------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index f75018fbdaf..a4df9ad3389 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1173,4 +1173,39 @@ $(document).ready(function() { } }); + +// Code to manage the js for combo list with dependencies (called by extrafields_view.tpl.php) +function showOptions(child_list, parent_list) { + var parentInput = $("select[name="+parent_list+"]"); + if (parentInput.length === 0) { // when parent extra-field is in view mode and the child is edited directly on card (on line edit) + parentInput = $("input[name="+parent_list+"]"); + } + if (parentInput.length > 0) { + var val = parentInput.val(); + var parentVal = parent_list + ":" + val; + if (val > 0) { + $("select[name=\""+child_list+"\"] option[parent]").prop("disabled", true).hide(); // hide not work with select2 element so disabled it + $("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").prop('disabled', false).show(); // show not work with select2 element so enabled it + } else { + $("select[name=\""+child_list+"\"] option").prop("disabled", false).show(); // show not work with select2 element so enabled it + } + } +} +function setListDependencies() { + console.log("setListDependencies"); + jQuery("select option[parent]").parent().each(function() { + var child_list = $(this).attr("name"); + var parent = $(this).find("option[parent]:first").attr("parent"); + var infos = parent.split(":"); + var parent_list = infos[0]; + showOptions(child_list, parent_list); + + /* Activate the handler to call showOptions on each future change */ + $("select[name=\""+parent_list+"\"]").change(function() { + showOptions(child_list, parent_list); + }); + }); +} + + // End of lib_head.js.php diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index cc0ee2b0f93..a328c9fe610 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -257,6 +257,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l } else { //var_dump($tmpkeyextra.'-'.$value.'-'.$object->table_element); print $extrafields->showOutputField($tmpkeyextra, $value, '', $object->table_element); + print ''; // it's needed when to get parent value when extra-field list depend on parent extra-field list } print ''; @@ -271,31 +272,6 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l print ' '."\n";