Comment 4 for bug 743890

Revision history for this message
Ferdinand (office-chricar) wrote :

IMHO it's the contrary - missing ids

class product_product(osv.osv):
    _inherit = "product.product"

    # FIXME this returns correct records, but group by catagory ignores this and uses all results for grouping
    # opening a category crashes
    def read(self,cr, uid, ids, fields=None, context=None, load='_classic_read'):
        res_all = super(product_product, self).read(cr,uid, ids, fields, context, load='_classic_read')
        res = []
        if context.get('display_with_zero_qty') == False:
          for prod in res_all:
            qty = prod.get('qty_available')
            vir = prod.get('virtual_available')
            if qty <> 0.0 or vir <> 0.0:
               res.append(prod)
        else:
            res = res_all
        # FIXME - result should be sorted by name
        # http://wiki.python.org/moin/SortingListsOfDictionaries - returns (unicode?) error on name
       return res
product_product()