This error probably stems from the useless complexity of the SQL view declaration and the double GROUP BY levels. The patch rewrites the view query with a single GROUP BY level and proper aggregation levels, but the core part of the patch is to replace the outer `group by product_qty` with a `sum(product_qty)`. Some columns were also mentioned twice in the same GROUP BY clause, for some reason. bzr revid: odo@openerp.com-20131025103626-7l78kdjjr7c2wesb