[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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user