Skip to content

Commit

Permalink
[FIX] sale: product sold stat button
Browse files Browse the repository at this point in the history
  • Loading branch information
antonylesuisse committed Jan 28, 2015
1 parent a35e985 commit a8edd21
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions addons/sale/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,15 +1261,17 @@ class product_product(osv.Model):
_inherit = 'product.product'

def _sales_count(self, cr, uid, ids, field_name, arg, context=None):
SaleOrderLine = self.pool['sale.order.line']
return {
product_id: SaleOrderLine.search_count(cr,uid, [('product_id', '=', product_id)], context=context)
for product_id in ids
}
domain = [
('state', 'in', ['waiting_date','progress','manual', 'shipping_except', 'invoice_except', 'done']),
('product_id', 'in', ids),
]
r = {}
for group in self.pool['sale.report'].read_group(cr, uid, domain, ['product_id','product_uom_qty'], ['product_id'], context=context):
r[group['product_id'][0]] = group['product_uom_qty']
return r

_columns = {
'sales_count': fields.function(_sales_count, string='# Sales', type='integer'),

}

class product_template(osv.Model):
Expand Down

0 comments on commit a8edd21

Please sign in to comment.