[IMP] *_timesheet: improve tests
This commit only improve timesheet tests, by adding more assertions.
This commit is contained in:
@@ -82,6 +82,7 @@ class TestTimesheet(TestCommonTimesheet):
|
||||
def test_log_timesheet(self):
|
||||
""" Test when log timesheet : check analytic account, user and employee are correctly set. """
|
||||
Timesheet = self.env['account.analytic.line']
|
||||
timesheet_uom = self.project_customer.analytic_account_id.company_id.project_time_mode_id
|
||||
# employee 1 log some timesheet on task 1
|
||||
timesheet1 = Timesheet.sudo(self.user_employee.id).create({
|
||||
'project_id': self.project_customer.id,
|
||||
@@ -92,6 +93,7 @@ class TestTimesheet(TestCommonTimesheet):
|
||||
self.assertEquals(timesheet1.account_id, self.project_customer.analytic_account_id, 'Analytic account should be the same as the project')
|
||||
self.assertEquals(timesheet1.employee_id, self.empl_employee, 'Employee should be the one of the current user')
|
||||
self.assertEquals(timesheet1.partner_id, self.task1.partner_id, 'Customer of task should be the same of the one set on new timesheet')
|
||||
self.assertEquals(timesheet1.product_uom_id, timesheet_uom, "The UoM of the timesheet should be the one set on the company of the analytic account.")
|
||||
|
||||
# employee 1 cannot log timesheet for employee 2
|
||||
with self.assertRaises(AccessError):
|
||||
@@ -113,6 +115,7 @@ class TestTimesheet(TestCommonTimesheet):
|
||||
})
|
||||
timesheet3._onchange_employee_id()
|
||||
self.assertEquals(timesheet3.user_id, self.user_employee2, 'Timesheet user should be the one linked to the given employee')
|
||||
self.assertEquals(timesheet3.product_uom_id, timesheet_uom, "The UoM of the timesheet 3 should be the one set on the company of the analytic account.")
|
||||
|
||||
# employee 1 log some timesheet on project (no task)
|
||||
timesheet4 = Timesheet.sudo(self.user_employee.id).create({
|
||||
|
||||
@@ -259,6 +259,38 @@ class TestProjectBilling(TestCommonSaleTimesheetNoChart):
|
||||
self.assertEqual(task.billable_type, 'task_rate', "Subtask should keep the billable type from its parent, even when they are moved into another project")
|
||||
self.assertEqual(task.sale_line_id, self.project_task_rate.sale_line_id, "Subtask should keep the same sale order line than their mother, even when they are moved into another project")
|
||||
|
||||
# create a second task in employee rate project
|
||||
task2 = Task.with_context(default_project_id=self.project_employee_rate.id).create({
|
||||
'name': 'first task',
|
||||
'partner_id': self.partner_customer_usd.id,
|
||||
'sale_line_id': False
|
||||
})
|
||||
|
||||
# log timesheet on task in 'employee rate' project without any fallback (no map, no SOL on task, no SOL on project)
|
||||
timesheet3 = Timesheet.create({
|
||||
'name': 'Test Line',
|
||||
'project_id': task2.project_id.id,
|
||||
'task_id': task2.id,
|
||||
'unit_amount': 3,
|
||||
'employee_id': self.employee_tde.id,
|
||||
})
|
||||
|
||||
self.assertFalse(timesheet3.so_line, "The timesheet should not be linked to SOL as there is no fallback at all (no map, no SOL on task, no SOL on project)")
|
||||
|
||||
# add a SOL on the project as fallback
|
||||
self.project_employee_rate.write({'sale_line_id': self.so1_line_deliver_no_task.id})
|
||||
|
||||
# log timesheet on task in 'employee rate' project wit the project fallback only (no map, no SOL on task, but SOL on project)
|
||||
timesheet4 = Timesheet.create({
|
||||
'name': 'Test Line ',
|
||||
'project_id': task2.project_id.id,
|
||||
'task_id': task2.id,
|
||||
'unit_amount': 4,
|
||||
'employee_id': self.employee_tde.id,
|
||||
})
|
||||
|
||||
self.assertEquals(timesheet4.so_line, self.so1_line_deliver_no_task, "The timesheet should be linked to SOL on the project, as no entry for TDE in project map and no SOL on task")
|
||||
|
||||
def test_billing_task_rate(self):
|
||||
""" Check task and subtask creation, and timesheeting in a project billed at 'task rate'. Then move the task into a 'employee rate' project then, 'non billable'. """
|
||||
Task = self.env['project.task'].with_context(tracking_disable=True)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.sale_timesheet.tests.common import TestCommonSaleTimesheetNoChart
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class TestSaleService(TestCommonSaleTimesheetNoChart):
|
||||
@@ -90,6 +90,10 @@ class TestSaleService(TestCommonSaleTimesheetNoChart):
|
||||
|
||||
self.assertEqual(self.sale_order.tasks_count, 2, "Adding a new service line on a confirmer SO should create a new task.")
|
||||
|
||||
# not possible to delete a task linked to a SOL
|
||||
with self.assertRaises(ValidationError):
|
||||
task.unlink()
|
||||
|
||||
def test_timesheet_uom(self):
|
||||
""" Test timesheet invoicing and uom conversion """
|
||||
# create SO and confirm it
|
||||
|
||||
Reference in New Issue
Block a user