The starting table for Purchase Analysis is purchase_order_line not purchase_order. The previous code was using a wrong JOIN combination starting from purchase_order, which resulted in a crash if an empty PO was created. In order to prevent this an extra WHERE clause on product_id being NOT NULL was added, but this was incorrect too as it prevented PO lines with no product_id value from appearing in the Purchase Analysis results, while being perfectly valid. bzr revid: odo@openerp.com-20131104165826-kltuzlh4i8q89sk0