Skip to content

Commit

Permalink
[ADD] helpdesk_mgmt_timesheet: original files from PR OCA#121
Browse files Browse the repository at this point in the history
  • Loading branch information
dalonsod committed Jul 28, 2020
1 parent 94f6b56 commit 142535b
Show file tree
Hide file tree
Showing 15 changed files with 402 additions and 0 deletions.
4 changes: 4 additions & 0 deletions helpdesk_mgmt_timesheet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
###############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
###############################################################################
from . import models
25 changes: 25 additions & 0 deletions helpdesk_mgmt_timesheet/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2020 Aresoltec Canarias <www.aresoltec.com>
# Copyright (C) 2020 Punt Sistemes <www.puntsistemes.es.es>
# Copyright (C) 2020 SDi Soluciones Digitales <www.sdi.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
'name': 'Helpdesk Ticket Timesheet',
'summary': 'Add HR Timesheet to the tickets for Helpdesk Management.',
'author': 'Aresoltec Canarias, '
'Punt Sistemes, '
'SDi Soluciones Digitales, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/oca/helpdesk',
'license': 'AGPL-3',
'category': 'After-Sales',
'version': '12.0.1.0.0',
'depends': [
'helpdesk_mgmt',
'account',
],
'data': [
'views/helpdesk_team.xml',
'views/helpdesk_ticket.xml',
]
}
104 changes: 104 additions & 0 deletions helpdesk_mgmt_timesheet/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * helpdesk_mgmt_timesheet
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 07:54+0000\n"
"PO-Revision-Date: 2020-05-19 10:00+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: es\n"
"X-Generator: Poedit 2.3.1\n"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket__allow_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket_team__allow_timesheet
msgid "Allow Timesheet"
msgstr "Permitir Partes de Horas"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket__analytic_account_id
msgid "Analityc Account"
msgstr "Cuenta analítica"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model,name:helpdesk_mgmt_timesheet.model_account_analytic_line
msgid "Analytic Line"
msgstr "Línea Analítica"

#. module: helpdesk_mgmt_timesheet
#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_timesheet.timesheet_helpdesk_team_view_form
msgid "Change the Default Analytic Account will not have retroactive effects."
msgstr "Cambiar la cuenta analítica por defecto no tendrá efectos retroactivos."

#. module: helpdesk_mgmt_timesheet
#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_timesheet.timesheet_helpdesk_team_view_form
msgid "Clean Default Analytic Account"
msgstr "Eliminar cuenta analítica por defecto"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket_team__default_analytic_account
msgid "Default Analytic Account"
msgstr "Cuenta analítica por defecto"

#. module: helpdesk_mgmt_timesheet
#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_timesheet.timesheet_helpdesk_ticket_view_form
msgid "Duration (Hour(s))"
msgstr "Duración (Hora(s))"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model,name:helpdesk_mgmt_timesheet.model_helpdesk_ticket
msgid "Helpdesk Ticket"
msgstr "Ticket Helpdesk"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model,name:helpdesk_mgmt_timesheet.model_helpdesk_ticket_team
msgid "Helpdesk Ticket Team"
msgstr "Equipo de ticket Helpdesk"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket__planned_hours
msgid "Planned Hours"
msgstr "Horas planeadas"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket__progress
msgid "Progress"
msgstr "En proceso"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket__remaining_hours
msgid "Remaining Hours"
msgstr "Horas restantes"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket_team__reset_default_analytic_account
msgid "Reset Analytic Account"
msgstr "Restablecer cuenta analítica"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket__timesheet_ids
msgid "Timesheet"
msgstr "Parte de Horas"

#. module: helpdesk_mgmt_timesheet
#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_timesheet.timesheet_helpdesk_ticket_view_form
msgid "Timesheets"
msgstr "Partes de horas"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_helpdesk_ticket__total_hours
msgid "Total Hours"
msgstr "Total horas"

#. module: helpdesk_mgmt_timesheet
#: model:ir.model.fields,field_description:helpdesk_mgmt_timesheet.field_account_analytic_line__ticket_id
msgid "Ticket"
msgstr "Ticket"
6 changes: 6 additions & 0 deletions helpdesk_mgmt_timesheet/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
###############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
###############################################################################
from . import account_analytic_line
from . import helpdesk_ticket
from . import helpdesk_ticket_team
13 changes: 13 additions & 0 deletions helpdesk_mgmt_timesheet/models/account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
###############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
###############################################################################
from odoo import fields, models


class AccountAnalyticLine(models.Model):
_inherit = 'account.analytic.line'

ticket_id = fields.Many2one(
comodel_name='helpdesk.ticket',
string='Ticket',
)
78 changes: 78 additions & 0 deletions helpdesk_mgmt_timesheet/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
###############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
###############################################################################
from odoo import api, fields, models


class HelpdeskTicket(models.Model):
_inherit = 'helpdesk.ticket'

allow_timesheet = fields.Boolean(
string='Allow Timesheet',
related='team_id.allow_timesheet',
)
analytic_account_id = fields.Many2one(
comodel_name='account.analytic.account',
string='Analityc Account',
)
planned_hours = fields.Float(
string='Planned Hours',
track_visibility='onchange',
)
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='impute_hours',
readonly=True,
store=True,
string='Total Hours'
)

@api.depends('timesheet_ids.unit_amount')
def impute_hours(self):
for record in self:
record.total_hours = sum(
record.timesheet_ids.mapped('unit_amount')
)

@api.constrains('analytic_account_id')
def _constrains_account_timesheets(self):
for record in self:
record.timesheet_ids.update({
'account_id': record.analytic_account_id.id
})

@api.onchange('team_id')
def _onchange_team_id(self):
for record in self:
record.analytic_account_id = \
record.team_id.default_analytic_account

@api.depends('planned_hours', 'total_hours')
def _compute_progress_hours(self):
for ticket in self:
ticket.progress = 0.0
if (ticket.planned_hours > 0.0):
if ticket.total_hours > ticket.planned_hours:
ticket.progress = 100
else:
ticket.progress = round(
100.0 * ticket.total_hours / ticket.planned_hours,
2
)
ticket.remaining_hours = ticket.planned_hours - ticket.total_hours
27 changes: 27 additions & 0 deletions helpdesk_mgmt_timesheet/models/helpdesk_ticket_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
###############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
###############################################################################
from odoo import api, fields, models


class HelpdeskTicketTeam(models.Model):
_inherit = 'helpdesk.ticket.team'

allow_timesheet = fields.Boolean(
string='Allow Timesheet',
)
default_analytic_account = fields.Many2one(
comodel_name='account.analytic.account',
string='Default Analytic Account',
)
reset_default_analytic_account = fields.Boolean(
string='Reset Analytic Account',
)

@api.constrains('allow_timesheet')
def _constrains_allow_timesheet(self):
if not self.allow_timesheet:
self.default_analytic_account = False

def action_clear(self):
self.default_analytic_account = False
12 changes: 12 additions & 0 deletions helpdesk_mgmt_timesheet/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
To configure this module, you need to:

#. Allow Timesheet for a Helpdesk's Team
#. Set a Default Analytic Account (optional)

Allow Timesheet
~~~~~~~~~~~~~~~

#. Go to Helpdesk > Configuration > Teams.
#. Edit or create a new team.
#. Check Allow Timesheet option to allow timesheets for that team.
#. Select a Default Analytic Account for that team (optional).
12 changes: 12 additions & 0 deletions helpdesk_mgmt_timesheet/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
* `Aresoltec Canarias, S.L <https://www.aresoltec.com>`_:

* Inma Sánchez

* `SDi Soluciones, S.L. <https://www.sdi.es>`_:

* Oscar Soto
* Jorge Luis Quinteros

* `Punt Sistemes, S.L. <https://www.puntsistemes.es/>`_:

* Carlos Ramos
1 change: 1 addition & 0 deletions helpdesk_mgmt_timesheet/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module add Timesheet funcionality in Helpdesk module.
3 changes: 3 additions & 0 deletions helpdesk_mgmt_timesheet/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#. Go to *Helpdesk* or *Helpdesk > Dashboard* to see the tickets dashboard.
#. In the Kanban view, click in the kanban card of a team to see their tickets and create new ones.
#. If there is not a Default Analytic Account you will need select an Analytic Account for the Ticket to show the Timesheet Table.
4 changes: 4 additions & 0 deletions helpdesk_mgmt_timesheet/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
###############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
###############################################################################
from . import tests_helpdesk_ticket
48 changes: 48 additions & 0 deletions helpdesk_mgmt_timesheet/tests/tests_helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
###############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
###############################################################################
import logging
from odoo.addons.helpdesk_mgmt.tests import test_helpdesk_ticket
from odoo import fields

_log = logging.getLogger(__name__)


class TestHelpdeskTicketTimesheet(test_helpdesk_ticket.TestHelpdeskTicket):

@classmethod
def setUpClass(cls):
super(TestHelpdeskTicketTimesheet, cls).setUpClass()
cls.account_id = cls.env['account.analytic.account'].create({
'name': 'Test Account',
})
cls.team_id = cls.env['helpdesk.ticket.team'].create({
'name': "Team 1",
'allow_timesheet': True,
'default_analytic_account': cls.account_id.id,
})

def generate_timesheet(self, hours=1.0):
return self.env['account.analytic.line'].create({
'amount': 0,
'company_id': 1,
'date': fields.Date.today(),
'name': 'Test Timesheet',
'unit_amount': hours,
})

def generate_ticket(self):
return self.env['helpdesk.ticket'].create({
'name': 'Test Ticket 1',
'team_id': self.team_id.id,
})

def test_total_and_remaining_hours(self):
ticket = self.generate_ticket()
ticket.planned_hours = 5
timesheet1 = self.generate_timesheet(2)
timesheet1.ticket_id = ticket.id
timesheet2 = self.generate_timesheet(1)
timesheet2.ticket_id = ticket.id
self.assertEqual(ticket.total_hours, 3)
self.assertEqual(ticket.remaining_hours, 2)
16 changes: 16 additions & 0 deletions helpdesk_mgmt_timesheet/views/helpdesk_team.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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 name="default_analytic_account" attrs="{'invisible':[('allow_timesheet', '=', False)]}" help=" Change the Default Analytic Account will not have retroactive effects."/>
<button name="action_clear" help=" Clean Default Analytic Account" type="object" icon="fa-trash" attrs="{'invisible':['|',('allow_timesheet', '=', False),('default_analytic_account', '=', False)]}" class="oe_highlight" />
</xpath>
</field>
</record>
</data>
Loading

0 comments on commit 142535b

Please sign in to comment.