pluginsGLPI / order

Order plugin for GLPI
GNU General Public License v3.0
39 stars 44 forks source link

Fix auto generation for "reference free" items #353

Closed AdrienClairembault closed 1 year ago

AdrienClairembault commented 1 year ago

"Reference free" items (which is not a correct translation of "Référence libre" IMO) can be used to add items to orders without defining their itemtypes.

image

Since these items do not have an itemtype, we can't generate any GLPI items for them on delivery. This mean on the "Associated items" tab, there is no checkbox to run massive actions for these items:

image

For comparison, here is another order with real item references, you can see the checkboxed are available in this case:

image

So the TLDR is that reference free item cant be generated as the checkbox are not displayed (which is normal). However, there is an option to enable auto generation on item delivery:

image

With this option active, the plugin will try to generate all items when they are marked as "delivered", even if they are reference free. This trigger an exception:

[2023-04-07 11:50:07] glpiphplog.CRITICAL:   *** Uncaught Exception Error: Class name must be a valid object or a string in /home/aclai/localhost/glpi/10.0-bugfixes/plugins/order/inc/link.class.php at line 1042
  Backtrace :
  plugins/order/inc/reception.class.php:994          PluginOrderLink->generateNewItem()
  plugins/order/inc/reception.class.php:868          PluginOrderReception::generateAsset()
  plugins/order/inc/reception.class.php:599          PluginOrderReception->updateReceptionStatus()
  src/MassiveAction.php:1408                         PluginOrderReception::processMassiveActionsForOneItemtype()
  src/MassiveAction.php:1386                         MassiveAction->processForSeveralItemtypes()
  front/massiveaction.php:59                         MassiveAction->process()

To fix this, I've blacklisted empty itemtypes (which reference free item use as their value) from item generations.