[MERGE] forward port of branch 8.0 up to 491372e
[odoo/odoo.git] / addons / sale_crm / crm_lead.py
1 from openerp.osv import osv, fields
2
3
4 class crm_lead(osv.Model):
5     _inherit = 'crm.lead'
6
7     def _get_sale_amount_total(self, cr, uid, ids, fields, args, context=None):
8         res = dict.fromkeys(ids, False)
9         sale_rec = self.pool['sale.order'].read_group(cr, uid, [('opportunity_id', 'in', ids), ('state', '!=', 'cancel')], ['opportunity_id', 'amount_total'], ['opportunity_id'], context=context)
10         for key, value in dict(map(lambda x: (x['opportunity_id'] and x['opportunity_id'][0], x['amount_total']), sale_rec)).items():
11             res[key] = value
12         return res
13
14     _columns = {
15         'sale_amount_total': fields.function(_get_sale_amount_total, string="Total Amount Of Quotations", type="float")
16     }