Skip to content

Commit

Permalink
[MIG] helpdesk_mgmt_timesheet: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aromera committed Jul 3, 2023
1 parent 8fcbe56 commit a8aaaef
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 209 deletions.
3 changes: 1 addition & 2 deletions helpdesk_mgmt_timesheet/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
"website": "https://github.com/OCA/helpdesk",
"license": "AGPL-3",
"category": "After-Sales",
"version": "14.0.1.0.1",
"version": "16.0.1.0.0",
"depends": [
"helpdesk_mgmt_project",
"hr_timesheet",
"project_timesheet_time_control",
],
"data": [
"views/helpdesk_team_view.xml",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<odoo noupdate="1">
<record id="project_1" model="project.project">
<field name="name">Helpdesk general project</field>
</record>
Expand Down Expand Up @@ -34,5 +33,4 @@
<field name="task_id" ref="project_task_1" />
<field name="unit_amount" eval="2" />
</record>
</data>
</odoo>
33 changes: 3 additions & 30 deletions helpdesk_mgmt_timesheet/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class HelpdeskTicket(models.Model):
_name = "helpdesk.ticket"
_inherit = ["helpdesk.ticket", "hr.timesheet.time_control.mixin"]
_inherit = ["helpdesk.ticket"]

@api.model
def _relation_with_timesheet_line(self):
Expand All @@ -16,26 +16,24 @@ def _relation_with_timesheet_line(self):
string="Allow Timesheet",
related="team_id.allow_timesheet",
)
planned_hours = fields.Float(string="Planned Hours", tracking=True)
planned_hours = fields.Float(tracking=True)
progress = fields.Float(
compute="_compute_progress_hours",
group_operator="avg",
store=True,
string="Progress",
)
remaining_hours = fields.Float(
compute="_compute_progress_hours",
readonly=True,
store=True,
string="Remaining Hours",
)
timesheet_ids = fields.One2many(
comodel_name="account.analytic.line",
inverse_name="ticket_id",
string="Timesheet",
)
total_hours = fields.Float(
compute="_compute_total_hours", readonly=True, store=True, string="Total Hours"
compute="_compute_total_hours", readonly=True, store=True
)
last_timesheet_activity = fields.Date(
compute="_compute_last_timesheet_activity",
Expand Down Expand Up @@ -78,28 +76,3 @@ def _compute_last_timesheet_activity(self):
record.timesheet_ids
and record.timesheet_ids.sorted(key="date", reverse=True)[0].date
) or False

@api.depends(
"team_id.allow_timesheet",
"project_id.allow_timesheets",
"timesheet_ids.employee_id",
"timesheet_ids.unit_amount",
)
def _compute_show_time_control(self):
result = super()._compute_show_time_control()
for ticket in self:
if not (
ticket.project_id.allow_timesheets and ticket.team_id.allow_timesheet
):
ticket.show_time_control = False
return result

def button_start_work(self):
result = super().button_start_work()
result["context"].update(
{
"default_project_id": self.project_id.id,
"default_task_id": self.task_id.id,
}
)
return result
4 changes: 1 addition & 3 deletions helpdesk_mgmt_timesheet/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
class HelpdeskTicketTeam(models.Model):
_inherit = "helpdesk.ticket.team"

allow_timesheet = fields.Boolean(
string="Allow Timesheet",
)
allow_timesheet = fields.Boolean()
default_project_id = fields.Many2one(
comodel_name="project.project",
string="Default Project",
Expand Down
2 changes: 2 additions & 0 deletions helpdesk_mgmt_timesheet/report/report_timesheet_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
groups="helpdesk_mgmt.group_helpdesk_user"
/>
</xpath>
</template>
<template id="timesheet_table" inherit_id="hr_timesheet.timesheet_table">
<xpath expr="//table[hasclass('table-sm')]/thead/tr/th[3]" position="after">
<th
t-if="show_ticket"
Expand Down
28 changes: 14 additions & 14 deletions helpdesk_mgmt_timesheet/views/helpdesk_team_view.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<data>
<record id="timesheet_helpdesk_team_view_form" model="ir.ui.view">
<field name="name">timesheet.helpdesk.team.form.view</field>
<field name="model">helpdesk.ticket.team</field>
<field name="inherit_id" ref="helpdesk_mgmt.view_helpdesk_team_form" />
<field name="priority" eval="20" />
<field name="arch" type="xml">
<xpath expr="//field[@name='alias_user_id']" position="after">
<field name="allow_timesheet" type="checkbox" />
<field
<odoo>
<record id="timesheet_helpdesk_team_view_form" model="ir.ui.view">
<field name="name">timesheet.helpdesk.team.form.view</field>
<field name="model">helpdesk.ticket.team</field>
<field name="inherit_id" ref="helpdesk_mgmt.view_helpdesk_team_form" />
<field name="priority" eval="20" />
<field name="arch" type="xml">
<xpath expr="//field[@name='alias_user_id']" position="after">
<field name="allow_timesheet" type="checkbox" />
<field
name="default_project_id"
attrs="{'invisible':[('allow_timesheet', '=', False)]}"
help=" Change the Default Project will not have retroactive effects."
/>
</xpath>
</field>
</record>
</data>
</xpath>
</field>
</record>
</odoo>
140 changes: 4 additions & 136 deletions helpdesk_mgmt_timesheet/views/helpdesk_ticket_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<data>
<odoo>
<record id="helpdesk_ticket_view_search" model="ir.ui.view">
<field name="name">helpdesk.ticket.view.search</field>
<field name="model">helpdesk.ticket</field>
Expand Down Expand Up @@ -34,14 +34,7 @@
<field name="name">helpdesk.ticket.view.tree</field>
<field name="model">helpdesk.ticket</field>
<field name="inherit_id" ref="helpdesk_mgmt.ticket_view_tree" />
<field
name="groups_id"
eval="[(6, 0, [ref('hr_timesheet.group_hr_timesheet_user')])]"
/>
<field name="arch" type="xml">
<xpath expr="." position="attributes">
<attribute name="decoration-danger">remaining_hours &lt; 0</attribute>
</xpath>
<field name="last_stage_update" position="after">
<field
name="planned_hours"
Expand All @@ -57,64 +50,17 @@
name="remaining_hours"
widget="float_time"
groups="hr_timesheet.group_hr_timesheet_user"
decoration-danger="remaining_hours &lt; 0"
/>
</field>
<tree position="inside">
<field name="show_time_control" invisible="1" />
<button
name="button_start_work"
title="Start work"
string="Start work"
tabindex="-1"
type="object"
icon="fa-play-circle text-success"
attrs="{'invisible': [('show_time_control', '!=', 'start')]}"
class="oe_stat_button"
/>
<button
name="button_end_work"
title="End work"
string="Stop work"
tabindex="-1"
type="object"
icon="fa-stop-circle text-warning"
attrs="{'invisible': [('show_time_control', '!=', 'stop')]}"
class="oe_stat_button"
/>
</tree>
</field>
</record>
<record id="timesheet_helpdesk_ticket_view_form" model="ir.ui.view">
<field name="name">timesheet.helpdesk.ticket.form.view</field>
<field name="model">helpdesk.ticket</field>
<field name="inherit_id" ref="helpdesk_mgmt.ticket_view_form" />
<field
name="groups_id"
eval="[(6, 0, [ref('hr_timesheet.group_hr_timesheet_user')])]"
/>
<field name="priority" eval="20" />
<field name="arch" type="xml">
<div name="button_box" position="inside">
<field name="show_time_control" invisible="1" />
<button
name="button_start_work"
title="Start work"
string="Start work"
type="object"
icon="fa-play-circle text-success"
attrs="{'invisible': [('show_time_control', '!=', 'start')]}"
class="oe_stat_button"
/>
<button
name="button_end_work"
title="End work"
string="Stop work"
type="object"
icon="fa-stop-circle text-warning"
attrs="{'invisible': [('show_time_control', '!=', 'stop')]}"
class="oe_stat_button"
/>
</div>
<xpath expr="//field[@name='partner_email']" position="after">
<field name="allow_timesheet" invisible="1" />
</xpath>
Expand All @@ -137,64 +83,20 @@
name="timesheet_ids"
context="{'default_project_id': project_id, 'default_task_id': task_id}"
>
<tree editable="bottom" delete="true" default_order="date_time">
<tree editable="bottom" delete="true">
<field name="company_id" invisible="1" />
<field name="project_id" invisible="1" />
<field name="task_id" invisible="1" />
<field name="date" widget="date" invisible="1" />
<field name="date_time" string="Date" required="1" />
<field name="user_id" required="1" />
<field name="name" />
<field
name="unit_amount"
string="Duration (Hour(s))"
widget="float_time"
/>
<field name="show_time_control" invisible="1" />
<button
name="button_resume_work"
string="Resume work"
tabindex="-1"
type="object"
icon="fa-play-circle text-success"
attrs="{'invisible': [('show_time_control', '!=', 'resume')]}"
class="oe_stat_button"
/>
<button
name="button_end_work"
title="End work"
string="Stop work"
tabindex="-1"
type="object"
icon="fa-stop-circle text-warning"
attrs="{'invisible': [('show_time_control', '!=', 'stop')]}"
class="oe_stat_button"
/>
</tree>
<form>
<div class="oe_button_box" name="button_box">
<field name="show_time_control" invisible="1" />
<button
name="button_resume_work"
string="Resume work"
tabindex="-1"
type="object"
icon="fa-play-circle text-success"
attrs="{'invisible': [('show_time_control', '!=', 'resume')]}"
class="oe_stat_button"
context="{'show_created_timer': True}"
/>
<button
name="button_end_work"
title="End work"
string="Stop work"
tabindex="-1"
type="object"
icon="fa-stop-circle text-warning"
attrs="{'invisible': [('show_time_control', '!=', 'stop')]}"
class="oe_stat_button"
/>
</div>
<group>
<field name="date" />
<field name="user_id" />
Expand All @@ -215,40 +117,6 @@
</xpath>
</field>
</record>
<record model="ir.ui.view" id="helpdesk_ticket_kanban_view">
<field
name="name"
>helpdesk.ticket.kanban (in helpdesk_mgmt_timesheet_time_control)</field>
<field name="model">helpdesk.ticket</field>
<field name="inherit_id" ref="helpdesk_mgmt.view_helpdesk_ticket_kanban" />
<field
name="groups_id"
eval="[(6, 0, [ref('hr_timesheet.group_hr_timesheet_user')])]"
/>
<field name="arch" type="xml">
<xpath expr="//*[hasclass('oe_kanban_bottom_left')]" position="inside">
<field name="show_time_control" invisible="1" />
<a
name="button_start_work"
title="Start work"
attrs="{'invisible': [('show_time_control', '!=', 'start')]}"
class="o_kanban_inline_block fa fa-lg fa-play-circle text-success"
string="Start work"
tabindex="-1"
type="object"
/>
<a
name="button_end_work"
title="End work"
attrs="{'invisible': [('show_time_control', '!=', 'stop')]}"
class="o_kanban_inline_block fa fa-lg fa-stop-circle text-warning"
string="Stop work"
tabindex="-1"
type="object"
/>
</xpath>
</field>
</record>
<record id="ticket_view_form_project_required" model="ir.ui.view">
<field name="name">timesheet.helpdesk.ticket.form.view project required</field>
<field name="model">helpdesk.ticket</field>
Expand All @@ -261,4 +129,4 @@
</field>
</field>
</record>
</data>
</odoo>
Loading

0 comments on commit a8aaaef

Please sign in to comment.