GROUP BY clause / Aggregate function error
It looks like you might have to change your first few lines to reflect this:

CREATE VIEW product_variation_stock_view AS
SELECT
    product_variations.product_id AS product_id,
    product_variations.id AS product_variation_id,
    COALESCE(SUM(stocks.quantity) - COALESCE(SUM(product_variation_order.quantity), 0), 0) AS stock,
    CASE WHEN COALESCE(SUM(stocks.quantity) - COALESCE(SUM(product_variation_order.quantity), 0), 0) &gt; 0
        THEN true
        ELSE false
    END in_stock
GROUP BY product_variations.id, product_variations.product_id
FROM product_variations