I think you need something like (don't know the exact syntax top of my head)
... AND O/"Order".Order_ProductGroup=$objProductGroup ...
->
.. AND ( (O/"Order".Order_ProductGroup=$objProductGroup ) or ($objProductGroup = empty and O/"Order".Order_ProductGroup = empty)) ...
FROM "Order".OrderLine AS OL
INNER JOIN OL/"Order".OrderLine_Order/"Order"."Order" as O
WHERE O/"Order".Order_Supplier = $objSupplier AND O/"Order".Order_ProductGroup=$objProductGroup AND O/"Order".Order_Customer=$objCustomers AND O/"Order".Order_Agent=$objAgent
AND (OL/ProductionStatus='P' OR OL/ProductionStatus='S')
GROUP BY OL.SupplyChainMonth
SELECT
OL.SupplyChainMonth as MonthName,
SUM(OL/Pieces) as PiecesSupplyChain,
ORDER BY MonthName
$objSupplier and $objProductGroup are references to Mendix objects which are always set, $objAgent and $objCustomers are references to Mendix objects which can be set but also can be empty