[FIX] sale_timesheet: timesheet on milestone should be registered as fixed price

This commit is contained in:
Jérome Maes
2017-09-29 13:04:04 +02:00
parent 94f4b31070
commit f0cfc2dd65
2 changed files with 7 additions and 4 deletions
+2 -2
View File
@@ -91,7 +91,7 @@ class AccountAnalyticLine(models.Model):
'timesheet_invoice_type': 'non_billable_project' if not timesheet.task_id else 'non_billable',
}
# set the revenue and billable type according to the product and the SO line
if timesheet.task_id and so_line.product_id.type == 'service' and so_line.product_id.service_type == 'timesheet':
if timesheet.task_id and so_line.product_id.type == 'service':
# find the analytic account to convert revenue into its currency
analytic_account = timesheet.account_id
# convert the unit of mesure into hours
@@ -101,7 +101,7 @@ class AccountAnalyticLine(models.Model):
# calculate the revenue on the timesheet
if so_line.product_id.invoice_policy == 'delivery':
values['timesheet_revenue'] = analytic_account.currency_id.round(unit_amount * sale_price * (1-(so_line.discount/100)))
values['timesheet_invoice_type'] = 'billable_time'
values['timesheet_invoice_type'] = 'billable_time' if so_line.product_id.service_type == 'timesheet' else 'billable_fixed'
elif so_line.product_id.invoice_policy == 'order':
quantity_hour = unit_amount
if so_line.product_uom.category_id == timesheet_uom.category_id:
@@ -250,7 +250,7 @@ class TestSaleTimesheet(CommonTest):
self.assertEqual(sale_order.invoice_status, 'no', 'Sale Timesheet: manually product should not need to be invoiced on so confirmation')
# let's log some timesheets (on task and project)
self.env['account.analytic.line'].create({
timesheet1 = self.env['account.analytic.line'].create({
'name': 'Test Line',
'project_id': self.project_global.id, # global project
'task_id': so_line_manual_global_project.task_id.id,
@@ -258,13 +258,16 @@ class TestSaleTimesheet(CommonTest):
'employee_id': self.employee_manager.id,
})
self.env['account.analytic.line'].create({
timesheet2 = self.env['account.analytic.line'].create({
'name': 'Test Line',
'project_id': sale_order.project_project_id.id, # global project
'unit_amount': 3,
'employee_id': self.employee_manager.id,
})
self.assertEqual(so_line_manual_global_project.task_id.sale_line_id, so_line_manual_global_project, "Task from a milestone product should be linked to its SO line too")
self.assertEqual(timesheet1.timesheet_invoice_type, 'billable_fixed', "Milestone timesheet goes in billable fixed category")
self.assertTrue(float_is_zero(so_line_manual_global_project.qty_delivered, precision_digits=2), "Milestone Timesheeting should not incremented the delivered quantity on the SO line")
self.assertEqual(so_line_manual_global_project.qty_to_invoice, 0.0, "Manual service should not be affected by timesheet on their created task.")
self.assertEqual(so_line_manual_only_project.qty_to_invoice, 0.0, "Manual service should not be affected by timesheet on their created project.")
self.assertEqual(sale_order.invoice_status, 'no', 'Sale Timesheet: "invoice on delivery" should not need to be invoiced on so confirmation')