Skip to content

Conversation

@daryl40000
Copy link

  • Compatibilité: évite l’exécution des hooks Subtotal sur des objets non commerciaux (ex: Équipement: alarm/video) pour prévenir des erreurs 500 lors de la génération des PDF sur certains environnements (Linux).
  • Aucun impact fonctionnel sur les documents commerciaux (propales, commandes, factures…).

- Compatibilité: évite l’exécution des hooks Subtotal sur des objets non commerciaux (ex: Équipement: alarm/video) pour prévenir des erreurs 500 lors de la génération des PDF sur certains environnements (Linux).
- Aucun impact fonctionnel sur les documents commerciaux (propales, commandes, factures…).
*/
global $pdf,$conf, $langs;

// Guard: ignore non-commercial objects (e.g., equipement alarm/video) to avoid incompatibilities
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

définition de la liste $allowedElements en dur à 3 endroits différents (beforePDFCreation, afterPDFCreation, defineColumnField).
Si demain on doit ajouter reception ou un autre objet, il faudra modifier 3 blocs de code

Copy link
Contributor

@atm-jpb atm-jpb Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

le mieux est de passer par la classe Tsubtotal

/**
* List of Dolibarr elements compatible with Subtotal logic
* @var array
*/
public const ALLOWED_COMMERCIAL_ELEMENTS = array(
'propal',
'commande',
'facture',
'order_supplier',
'invoice_supplier',
'supplier_proposal',
'shipping',
'delivery'
); et de faire un appel dans ce genre là : if (empty($object->element) || !in_array($object->element, TSubtotal::ALLOWED_COMMERCIAL_ELEMENTS, true)) {
return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants