From 1156dc7ac7fcafa9a1d8793cd2003b548f0c7ed9 Mon Sep 17 00:00:00 2001 From: atm-jonathan <146709163+atm-jonathan@users.noreply.github.com> Date: Mon, 27 Jul 2026 12:45:51 +0200 Subject: [PATCH] Fix/supplier doc keep project (#39306) * FIX : situation invoice credit note wrong amount in progressive mode When creating a credit note "with same lines" from a situation invoice, the code always subtracts the previous situation invoice's line values before inverting the sign, assuming lines are stored cumulative (INVOICE_USE_SITUATION = 1, legacy mode). In progressive mode (INVOICE_USE_SITUATION = 2), each situation invoice line already stores its own delta amount and percent, so this extra subtraction credits the wrong amount and percent (e.g. 60% / 1272 instead of the correct 20% / 424 on a real cycle). Skip the subtraction in progressive mode so the credit note reuses the source line's own delta values, as expected. * FIX supplier order/proposal loses project after supplier selection On the create form of a supplier order (fourn/commande/card.php) and a supplier price request (supplier_proposal/card.php), the project select was filtered on the supplier third party as soon as one was chosen: the `if ($socid > 0)` branch took precedence over the PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS constant. As a result, a supplier document created from a customer project lost its preselected project when the page reloaded after picking the supplier (the customer project is not linked to the supplier, so it was filtered out). This aligns the behavior with the supplier invoice (fourn/facture/card.php), which gives priority to PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS. The external user restriction now targets $user->socid (the real external-user marker) instead of $socid > 0, which also matched internal users after selecting a supplier. --- htdocs/fourn/commande/card.php | 10 ++++++---- htdocs/supplier_proposal/card.php | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 6968b58dae1..9e828d2c0f6 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1838,12 +1838,14 @@ if ($action == 'create') { $langs->load('projects'); print '