[FIX] sale: product sold stat button
This commit is contained in:
parent
a35e9858dc
commit
a8edd217a0
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue