- SELECT oe.id AS id,
- CASE WHEN oe.quotation THEN oe.quonumber ELSE oe.ordnumber END AS number,
- CASE
- WHEN oe.customer_id IS NOT NULL AND COALESCE(oe.quotation, FALSE) THEN 'sales_quotation'
- WHEN oe.customer_id IS NOT NULL AND NOT COALESCE(oe.quotation, FALSE) THEN 'sales_order'
- WHEN oe.customer_id IS NULL AND COALESCE(oe.quotation, FALSE) THEN 'request_quotation'
- ELSE 'purchase_order'
- END AS type
- FROM oe
- WHERE oe.id = ?
-
- UNION
-