<dtml-comment>
title:
connection_id:erp5_sql_connection
max_rows:0
max_cache:0
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>order_list</params>
SELECT livraison.id, livraison.path, SUM(movement.quantity) AS quantity
FROM catalog AS ligne_livr, catalog AS commande, catalog AS livraison, movement, category
WHERE commande.portal_type="Samples Order"
AND ligne_livr.parent_uid=livraison.uid
AND ligne_livr.portal_type="Delivery Line"
AND movement.uid=ligne_livr.uid
AND livraison.uid=category.uid
AND commande.uid=category.category_uid
AND category.base_category_uid=<dtml-var "portal_categories.causality.uid">
AND livraison.portal_type="Samples Packing List"
AND livraison.delivery_state="expediee"
AND (commande.id = "<dtml-var expr="order_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(order_list)-1)">
OR commande.id = "<dtml-var expr="order_list[loop_item+1]">"
</dtml-in>
)
GROUP BY livraison.id
ORDER BY livraison.id
