-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] helpdesk_mgmt_timesheet: Migration 16.0
- Loading branch information
Aromera
committed
Aug 2, 2023
1 parent
2786b7e
commit 2ee2806
Showing
12 changed files
with
117 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 34 additions & 36 deletions
70
helpdesk_mgmt_timesheet/demo/helpdesk_mgmt_timesheet_demo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<data noupdate="1"> | ||
<record id="project_1" model="project.project"> | ||
<field name="name">Helpdesk general project</field> | ||
</record> | ||
<record id="project_task_1" model="project.task"> | ||
<field name="name">Helpdesk general task</field> | ||
<field name="project_id" ref="project_1" /> | ||
</record> | ||
<record id="helpdesk_mgmt.helpdesk_team_2" model="helpdesk.ticket.team"> | ||
<field name="allow_timesheet" eval="True" /> | ||
<field name="default_project_id" ref="project_1" /> | ||
</record> | ||
<record id="helpdesk_mgmt.helpdesk_ticket_1" model="helpdesk.ticket"> | ||
<field name="team_id" ref="helpdesk_mgmt.helpdesk_team_2" /> | ||
<field name="project_id" ref="project_1" /> | ||
<field name="task_id" ref="project_task_1" /> | ||
<field name="planned_hours" eval="5" /> | ||
</record> | ||
<record id="helpdesk_ticket_1_timesheet_1" model="account.analytic.line"> | ||
<field name="ticket_id" ref="helpdesk_mgmt.helpdesk_ticket_1" /> | ||
<field name="name">Initial analysis</field> | ||
<field name="user_id" ref='base.user_admin' /> | ||
<field name="project_id" ref="project_1" /> | ||
<field name="task_id" ref="project_task_1" /> | ||
<field name="unit_amount" eval="2.5" /> | ||
</record> | ||
<record id="helpdesk_ticket_1_timesheet_2" model="account.analytic.line"> | ||
<field name="ticket_id" ref="helpdesk_mgmt.helpdesk_ticket_1" /> | ||
<field name="name">Resolution</field> | ||
<field name="user_id" ref='base.user_admin' /> | ||
<field name="project_id" ref="project_1" /> | ||
<field name="task_id" ref="project_task_1" /> | ||
<field name="unit_amount" eval="2" /> | ||
</record> | ||
</data> | ||
<odoo noupdate="1"> | ||
<record id="project_1" model="project.project"> | ||
<field name="name">Helpdesk general project</field> | ||
</record> | ||
<record id="project_task_1" model="project.task"> | ||
<field name="name">Helpdesk general task</field> | ||
<field name="project_id" ref="project_1" /> | ||
</record> | ||
<record id="helpdesk_mgmt.helpdesk_team_2" model="helpdesk.ticket.team"> | ||
<field name="allow_timesheet" eval="True" /> | ||
<field name="default_project_id" ref="project_1" /> | ||
</record> | ||
<record id="helpdesk_mgmt.helpdesk_ticket_1" model="helpdesk.ticket"> | ||
<field name="team_id" ref="helpdesk_mgmt.helpdesk_team_2" /> | ||
<field name="project_id" ref="project_1" /> | ||
<field name="task_id" ref="project_task_1" /> | ||
<field name="planned_hours" eval="5" /> | ||
</record> | ||
<record id="helpdesk_ticket_1_timesheet_1" model="account.analytic.line"> | ||
<field name="ticket_id" ref="helpdesk_mgmt.helpdesk_ticket_1" /> | ||
<field name="name">Initial analysis</field> | ||
<field name="user_id" ref='base.user_admin' /> | ||
<field name="project_id" ref="project_1" /> | ||
<field name="task_id" ref="project_task_1" /> | ||
<field name="unit_amount" eval="2.5" /> | ||
</record> | ||
<record id="helpdesk_ticket_1_timesheet_2" model="account.analytic.line"> | ||
<field name="ticket_id" ref="helpdesk_mgmt.helpdesk_ticket_1" /> | ||
<field name="name">Resolution</field> | ||
<field name="user_id" ref='base.user_admin' /> | ||
<field name="project_id" ref="project_1" /> | ||
<field name="task_id" ref="project_task_1" /> | ||
<field name="unit_amount" eval="2" /> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,16 +23,22 @@ def setUpClass(cls): | |
"default_project_id": cls.project_id.id, | ||
} | ||
) | ||
|
||
def generate_timesheet(self, ticket, hours=1.0, days_ago=0): | ||
return self.env["account.analytic.line"].create( | ||
# users | ||
cls.user_employee = cls.env["res.users"].create( | ||
{ | ||
"amount": 0, | ||
"date": fields.Date.today() - timedelta(days=days_ago), | ||
"name": "Test Timesheet", | ||
"unit_amount": hours, | ||
"ticket_id": ticket.id, | ||
"project_id": ticket.project_id.id, | ||
"name": "User Employee", | ||
"login": "user_employee", | ||
"email": "[email protected]", | ||
"groups_id": [ | ||
(6, 0, [cls.env.ref("hr_timesheet.group_hr_timesheet_user").id]) | ||
], | ||
} | ||
) | ||
# employees | ||
cls.empl_employee = cls.env["hr.employee"].create( | ||
{ | ||
"name": "User Empl Employee", | ||
"user_id": cls.user_employee.id, | ||
} | ||
) | ||
|
||
|
@@ -46,18 +52,35 @@ def generate_ticket(self): | |
) | ||
|
||
def test_helpdesk_mgmt_timesheet(self): | ||
Timesheet = self.env["account.analytic.line"] | ||
ticket = self.generate_ticket() | ||
self.assertFalse(ticket.last_timesheet_activity) | ||
ticket._onchange_team_id() | ||
self.assertEqual(ticket.project_id.id, self.team_id.default_project_id.id) | ||
ticket.planned_hours = 5 | ||
days_ago = 1 | ||
timesheet1 = self.generate_timesheet(ticket, hours=2, days_ago=days_ago) | ||
timesheet1 = Timesheet.with_user(self.user_employee).create( | ||
{ | ||
"date": fields.Date.today() - timedelta(days=days_ago), | ||
"name": "Test Timesheet", | ||
"unit_amount": 2, | ||
"ticket_id": ticket.id, | ||
"project_id": ticket.project_id.id, | ||
} | ||
) | ||
self.assertEqual( | ||
ticket.last_timesheet_activity, | ||
fields.Date.today() - timedelta(days=days_ago), | ||
) | ||
timesheet2 = self.generate_timesheet(ticket, hours=1) | ||
timesheet2 = Timesheet.with_user(self.user_employee).create( | ||
{ | ||
"date": fields.Date.today() - timedelta(days=0), | ||
"name": "Test Timesheet", | ||
"unit_amount": 1, | ||
"ticket_id": ticket.id, | ||
"project_id": ticket.project_id.id, | ||
} | ||
) | ||
self.assertEqual(ticket.last_timesheet_activity, fields.Date.today()) | ||
self.assertEqual( | ||
ticket.total_hours, timesheet1.unit_amount + timesheet2.unit_amount | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.