From a980376bfa58ef82d3055fd906258a00e6d2986b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Fri, 1 Sep 2017 10:23:59 +0200 Subject: [PATCH] [FIX] sale_timesheet: avoid crash when comparing UoM of different category If not UoM set, timesheet UoM is hours by default and product one is Units. We can consider 1 unit = 1 hour. --- addons/sale_timesheet/models/account.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index 55683a33745..bbcec43e025 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -123,7 +123,9 @@ class AccountAnalyticLine(models.Model): revenue = analytic_account.currency_id.round(unit_amount * sale_price * (1-(so_line.discount/100))) billable_type = 'billable_time' elif so_line.product_id.invoice_policy == 'order' and so_line.product_id.track_service == 'task': - quantity_hour = so_line.product_uom._compute_quantity(so_line.product_uom_qty, timesheet_uom) + quantity_hour = unit_amount + if so_line.product_uom.category_id == timesheet_uom.category_id: + quantity_hour = so_line.product_uom._compute_quantity(so_line.product_uom_qty, timesheet_uom) # compute the total revenue the SO since we are in fixed price total_revenue_so = analytic_account.currency_id.round(quantity_hour * sale_price * (1-(so_line.discount/100))) # compute the total revenue already existing (without the current timesheet line)