mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] sale_timesheet_work_entry_rate: to Odoo 15.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Timesheet Billing Rate',
|
'name': 'Timesheet Billing Rate',
|
||||||
'version': '14.0.1.0.1',
|
'version': '15.0.1.0.0',
|
||||||
'category': 'Sale',
|
'category': 'Sale',
|
||||||
'author': 'Hibou Corp.',
|
'author': 'Hibou Corp.',
|
||||||
'license': 'OPL-1',
|
'license': 'OPL-1',
|
||||||
|
|||||||
@@ -11,17 +11,13 @@ class TestSaleFlow(TestProjectBilling):
|
|||||||
Task = self.env['project.task'].with_context(tracking_disable=True)
|
Task = self.env['project.task'].with_context(tracking_disable=True)
|
||||||
Timesheet = self.env['account.analytic.line']
|
Timesheet = self.env['account.analytic.line']
|
||||||
|
|
||||||
# set subtask project on task rate project
|
|
||||||
self.project_task_rate.write({'subtask_project_id': self.project_subtask.id})
|
|
||||||
|
|
||||||
# create a task
|
# create a task
|
||||||
task = Task.with_context(default_project_id=self.project_task_rate.id).create({
|
task = Task.with_context(default_project_id=self.project_task_rate.id).create({
|
||||||
'name': 'first task',
|
'name': 'first task',
|
||||||
})
|
})
|
||||||
task._onchange_project()
|
|
||||||
|
|
||||||
self.assertEqual(task.sale_line_id, self.project_task_rate.sale_line_id, "Task created in a project billed on 'task rate' should be linked to a SOL of the project")
|
self.assertEqual(task.sale_line_id, self.so2_line_deliver_project_task, "Task created in a project billed on 'task rate' should be linked to a SOL containing a prepaid service product and the remaining hours of this SOL should be greater than 0.")
|
||||||
self.assertEqual(task.partner_id, task.project_id.partner_id, "Task created in a project billed on 'employee rate' should have the same customer as the one from the project")
|
self.assertEqual(task.partner_id, task.project_id.partner_id, "Task created in a project billed on 'task rate' should have the same customer as the one from the project")
|
||||||
|
|
||||||
# log timesheet on task
|
# log timesheet on task
|
||||||
timesheet1 = Timesheet.create({
|
timesheet1 = Timesheet.create({
|
||||||
@@ -32,12 +28,13 @@ class TestSaleFlow(TestProjectBilling):
|
|||||||
'employee_id': self.employee_manager.id,
|
'employee_id': self.employee_manager.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.assertEqual(self.project_task_rate.sale_line_id, timesheet1.so_line, "The timesheet should be linked to the SOL associated to the Employee manager in the map")
|
self.assertEqual(task.sale_line_id, timesheet1.so_line, "The timesheet should be linked to the SOL associated to the task since the pricing type of the project is task rate.")
|
||||||
|
|
||||||
# create a subtask
|
# create a subtask
|
||||||
subtask = Task.with_context(default_project_id=self.project_task_rate.subtask_project_id.id).create({
|
subtask = Task.with_context(default_project_id=self.project_task_rate.id).create({
|
||||||
'name': 'first subtask task',
|
'name': 'first subtask task',
|
||||||
'parent_id': task.id,
|
'parent_id': task.id,
|
||||||
|
'display_project_id': self.project_subtask.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.assertEqual(subtask.partner_id, subtask.parent_id.partner_id, "Subtask should have the same customer as the one from their mother")
|
self.assertEqual(subtask.partner_id, subtask.parent_id.partner_id, "Subtask should have the same customer as the one from their mother")
|
||||||
@@ -45,46 +42,34 @@ class TestSaleFlow(TestProjectBilling):
|
|||||||
# log timesheet on subtask
|
# log timesheet on subtask
|
||||||
timesheet2 = Timesheet.create({
|
timesheet2 = Timesheet.create({
|
||||||
'name': 'Test Line on subtask',
|
'name': 'Test Line on subtask',
|
||||||
'project_id': subtask.project_id.id,
|
'project_id': subtask.display_project_id.id,
|
||||||
'task_id': subtask.id,
|
'task_id': subtask.id,
|
||||||
'unit_amount': 50,
|
'unit_amount': 50,
|
||||||
'employee_id': self.employee_user.id,
|
'employee_id': self.employee_user.id,
|
||||||
})
|
})
|
||||||
|
self.assertEqual(subtask.display_project_id, timesheet2.project_id, "The timesheet is in the subtask project")
|
||||||
self.assertEqual(subtask.project_id, timesheet2.project_id, "The timesheet is in the subtask project")
|
|
||||||
self.assertFalse(timesheet2.so_line, "The timesheet should not be linked to SOL as it's a non billable project")
|
self.assertFalse(timesheet2.so_line, "The timesheet should not be linked to SOL as it's a non billable project")
|
||||||
|
|
||||||
# move task and subtask into task rate project
|
# move task and subtask into task rate project
|
||||||
task.write({
|
task.write({
|
||||||
'project_id': self.project_employee_rate.id,
|
'project_id': self.project_employee_rate.id,
|
||||||
})
|
})
|
||||||
task._onchange_project()
|
|
||||||
subtask.write({
|
subtask.write({
|
||||||
'project_id': self.project_employee_rate.id,
|
'display_project_id': self.project_employee_rate.id,
|
||||||
})
|
})
|
||||||
subtask._onchange_project()
|
|
||||||
|
|
||||||
self.assertFalse(task.sale_line_id, "Task moved in a employee rate billable project have empty so line")
|
self.assertEqual(task.sale_line_id, self.project_task_rate.sale_line_id, "Task moved in a employee rate billable project should keep its SOL because the partner_id has not changed too.")
|
||||||
self.assertEqual(task.partner_id, task.project_id.partner_id, "Task created in a project billed on 'employee rate' should have the same customer as the one from the project")
|
self.assertEqual(task.partner_id, self.project_task_rate.partner_id, "Task created in a project billed on 'employee rate' should have the same customer as the one from its initial project.")
|
||||||
|
|
||||||
self.assertFalse(subtask.sale_line_id, "Subask moved in a employee rate billable project have empty so line")
|
self.assertEqual(subtask.sale_line_id, subtask.parent_id.sale_line_id, "Subtask moved in a employee rate billable project should have the SOL of its parent since it keep its partner_id and this partner is different than the one in the destination project.")
|
||||||
self.assertEqual(subtask.partner_id, task.project_id.partner_id, "Subask created in a project billed on 'employee rate' should have the same customer as the one from the project")
|
self.assertEqual(subtask.partner_id, subtask.parent_id.partner_id, "Subtask moved in a project billed on 'employee rate' should keep its initial customer, that is the one of its parent.")
|
||||||
|
|
||||||
# Work Entry Type
|
|
||||||
task.write({
|
|
||||||
'project_id': self.project_task_rate.id,
|
|
||||||
})
|
|
||||||
task._onchange_project()
|
|
||||||
subtask.write({
|
|
||||||
'project_id': self.project_task_rate.id,
|
|
||||||
})
|
|
||||||
subtask._onchange_project()
|
|
||||||
default_work_entry_type = self.env.ref('hr_timesheet_work_entry.work_input_timesheet')
|
default_work_entry_type = self.env.ref('hr_timesheet_work_entry.work_input_timesheet')
|
||||||
# Timesheets were for regular default 'Timesheet' type
|
# Timesheets were for regular default 'Timesheet' type
|
||||||
self.assertEqual((timesheet1 + timesheet2).mapped('work_type_id'), default_work_entry_type)
|
self.assertEqual((timesheet1 + timesheet2).mapped('work_type_id'), default_work_entry_type)
|
||||||
# Line is set and total adds up to all of the timesheets.
|
# Line is set and total adds up to all of the timesheets.
|
||||||
self.assertEqual(task.sale_line_id, self.so2_line_deliver_project_task)
|
self.assertEqual(task.sale_line_id, self.so2_line_deliver_project_task)
|
||||||
self.assertEqual(task.sale_line_id.qty_delivered, 100.0)
|
self.assertEqual(task.sale_line_id.qty_delivered, 50.0)
|
||||||
|
|
||||||
double_rate_work_entry_type = self.env.ref('sale_timesheet_work_entry_rate.work_input_timesheet_double')
|
double_rate_work_entry_type = self.env.ref('sale_timesheet_work_entry_rate.work_input_timesheet_double')
|
||||||
self.assertEqual(double_rate_work_entry_type.timesheet_billing_rate, 2.0)
|
self.assertEqual(double_rate_work_entry_type.timesheet_billing_rate, 2.0)
|
||||||
@@ -93,20 +78,23 @@ class TestSaleFlow(TestProjectBilling):
|
|||||||
timesheet1.write({
|
timesheet1.write({
|
||||||
'work_type_id': double_rate_work_entry_type.id,
|
'work_type_id': double_rate_work_entry_type.id,
|
||||||
})
|
})
|
||||||
self.assertEqual(task.sale_line_id.qty_delivered, 150.0)
|
self.assertEqual(task.sale_line_id.qty_delivered, 100.0)
|
||||||
|
|
||||||
# Ensure that a created timesheet WITHOUT a work entry type behaves
|
# Ensure that a created timesheet WITHOUT a work entry type behaves
|
||||||
# the same as it would have before this module (e.g. for historic reasons)
|
# the same as it would have before this module (e.g. for historic reasons)
|
||||||
|
timesheet1.write({
|
||||||
|
'work_type_id': False,
|
||||||
|
})
|
||||||
timesheet2.write({
|
timesheet2.write({
|
||||||
'work_type_id': False,
|
'work_type_id': False,
|
||||||
})
|
})
|
||||||
self.assertEqual(task.sale_line_id.qty_delivered, 150.0)
|
self.assertEqual(task.sale_line_id.qty_delivered, 50.0)
|
||||||
|
|
||||||
# Ensure we can bill zero even with above default.
|
# Ensure we can bill zero even with above default.
|
||||||
zero_rate_work_entry_type = self.env.ref('sale_timesheet_work_entry_rate.work_input_timesheet_free')
|
zero_rate_work_entry_type = self.env.ref('sale_timesheet_work_entry_rate.work_input_timesheet_free')
|
||||||
self.assertEqual(zero_rate_work_entry_type.timesheet_billing_rate, 0.0)
|
self.assertEqual(zero_rate_work_entry_type.timesheet_billing_rate, 0.0)
|
||||||
|
|
||||||
timesheet2.write({
|
timesheet1.write({
|
||||||
'work_type_id': zero_rate_work_entry_type.id,
|
'work_type_id': zero_rate_work_entry_type.id,
|
||||||
})
|
})
|
||||||
self.assertEqual(task.sale_line_id.qty_delivered, 100.0)
|
self.assertEqual(task.sale_line_id.qty_delivered, 0.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user