[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.
This commit is contained in:
Jérome Maes
2017-09-01 11:39:26 +02:00
parent cdbe2f0ed4
commit a980376bfa
+3 -1
View File
@@ -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)