summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérome Maes <jem@openerp.com>2017-09-28 11:58:59 +0200
committerJérome Maes <jem@openerp.com>2017-09-29 13:04:04 +0200
commitf0cfc2dd659a189f0cb4b178f28a8cf66feda2c0 (patch)
tree7263ec5e75947ee6112f180a4df82442adf8b586
parent94f4b3107021b83351b02e2d96ec093971b2359d (diff)
[FIX] sale_timesheet: timesheet on milestone should be registered as fixed price
-rw-r--r--addons/sale_timesheet/models/account.py4
-rw-r--r--addons/sale_timesheet/tests/test_sale_timesheet.py7
2 files changed, 7 insertions, 4 deletions
diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py
index bf947a4347e..2e6cb166eaf 100644
--- a/addons/sale_timesheet/models/account.py
+++ b/addons/sale_timesheet/models/account.py
@@ -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:
diff --git a/addons/sale_timesheet/tests/test_sale_timesheet.py b/addons/sale_timesheet/tests/test_sale_timesheet.py
index eefe4b26880..fa4b8d905fa 100644
--- a/addons/sale_timesheet/tests/test_sale_timesheet.py
+++ b/addons/sale_timesheet/tests/test_sale_timesheet.py
@@ -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')