From 29851b74aacc2ab54ecde1474839f78ebe03ef5f Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 6 Apr 2016 12:44:40 +0200 Subject: [PATCH] [FIX] sale_crm: if no company on lead use user currency When displaying the `sale_amount_total` of an opportunity, the amount of the related order are summed up in the opportunity company's currency. But when creating a lead, we can leave the company empty which warranted this commit adding in that instance a fall back on the current user company currency. closes #11611 opw-673167 --- addons/sale_crm/crm_lead.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale_crm/crm_lead.py b/addons/sale_crm/crm_lead.py index 80ddc53a874..77c05f1be2b 100644 --- a/addons/sale_crm/crm_lead.py +++ b/addons/sale_crm/crm_lead.py @@ -12,11 +12,12 @@ class crm_lead(models.Model): def _get_sale_amount_total(self): total = 0.0 nbr = 0 + company_currency = self.company_currency or self.env.user.company_id.currency_id for order in self.order_ids: if order.state in ('draft', 'sent'): nbr += 1 if order.state not in ('draft', 'sent', 'cancel'): - total += order.currency_id.compute(order.amount_untaxed, self.company_currency) + total += order.currency_id.compute(order.amount_untaxed, company_currency) self.sale_amount_total = total self.sale_number = nbr