<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params></params>
SELECT DISTINCT catalog.relative_url, catalog.path
FROM catalog, catalog as resource, catalog as delivery, movement
LEFT JOIN category
ON (category.uid=movement.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.uid">)
WHERE movement.uid = catalog.uid
AND movement.target_quantity <> 0
AND category.uid IS NULL
AND movement.is_accountable = 1
AND resource.uid = movement.resource_uid
AND resource.portal_type = "Tissu"
AND delivery.uid = movement.delivery_uid
AND (delivery.simulation_state = "getting_ready"
OR delivery.simulation_state = "started"
OR delivery.simulation_state = "delivered")
AND ( delivery.portal_type = "Production Packing List"
OR delivery.portal_type = "Movement MP" )