<dtml-comment>
title:
connection_id:erp5_sql_connection
max_rows:100000
max_cache:10
cache_time:60
class_name:
class_file:
</dtml-comment>
<params></params>
SELECT DISTINCT
	distinct item.uid
FROM
	catalog AS item

LEFT JOIN category
ON (category.category_uid=item.uid
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.getUid()">)

LEFT JOIN stock
ON (stock.uid = category.uid)

LEFT JOIN movement
ON (movement.uid = category.uid)

WHERE item.portal_type = "Piece Tissu"
AND stock.node_uid = <dtml-var "portal_categories.site.Stock_MP.Gravelines.getUid()">
AND stock.quantity < 0
AND movement.inventory IS NULL