query = "select sum(s.amount_total) as total , s.partner_id,
c.name from sale_order as s inner join res_partner as c
on s.partner_id =c.id group by s.partner_id,c.name
order by total desc"
//this will return the sum of amount_total group by custmer name ,
//you need to put this value inside the self.env.cr.execute(query)