diff --git a/timesheet_activity_report/README.rst b/timesheet_activity_report/README.rst new file mode 100644 index 00000000..ae17bd16 --- /dev/null +++ b/timesheet_activity_report/README.rst @@ -0,0 +1,56 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +========================= +Timesheet Activity Report +========================= + +This module extends the functionality of project adding a timesheet report listed at timesheet completion analysis. +You can use this report to communicate the timesheet analysis to the project members. + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + + +Contributors +------------ + +* Eric Caudal +* Sébastien Maillard +* Reinhard Sheng + + +This module is maintained by Elico Corporation. + +Elico Corp is an innovative actor in China, Hong-Kong and Singapore servicing +well known international companies and as well as local mid-sized businesses. +Since 2010, our seasoned Sino-European consultants have been providing full +range Odoo services: + +* Business consultancy for Gap analysis, BPM, operational work-flows review. +* Ready-to-use ERP packages aimed at starting businesses. +* Odoo implementation for manufacturing, international trading, service industry + and e-commerce. +* Connectors and integration with 3rd party software (Magento, Taobao, Coswin, + Joomla, Prestashop, Tradevine etc...). +* Odoo Support services such as developments, training, maintenance and hosting. + +Our headquarters are located in Shanghai with branch in Singapore servicing +customers from all over Asia Pacific. + +Contact information: `Sales `__ diff --git a/timesheet_activity_report/__init__.py b/timesheet_activity_report/__init__.py new file mode 100644 index 00000000..65ecf071 --- /dev/null +++ b/timesheet_activity_report/__init__.py @@ -0,0 +1 @@ +from . import report diff --git a/timesheet_activity_report/__manifest__.py b/timesheet_activity_report/__manifest__.py new file mode 100644 index 00000000..232da91b --- /dev/null +++ b/timesheet_activity_report/__manifest__.py @@ -0,0 +1,23 @@ +# © 2016-2019 Elico Corp (https://www.elico-corp.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +{ + 'name': 'Timesheet Activities Report', + 'version': '12.0.1.1.0', + 'category': 'Human Resources', + 'depends': [ + 'hr_timesheet', + 'helpdesk_timesheet', + 'business_requirement_deliverable_project', + 'project_task_category' + ], + 'author': 'Elico Corp', + 'support': 'support@elico-corp.com', + 'license': 'LGPL-3', + 'website': 'https://www.elico-corp.com', + 'data': [ + 'report/timesheet_activity_report_view.xml', + 'security/ir.model.access.csv', + ], + 'installable': True, + 'application': False +} diff --git a/timesheet_activity_report/report/__init__.py b/timesheet_activity_report/report/__init__.py new file mode 100644 index 00000000..9a6e12d9 --- /dev/null +++ b/timesheet_activity_report/report/__init__.py @@ -0,0 +1 @@ +from . import timesheet_activity_report diff --git a/timesheet_activity_report/report/timesheet_activity_report.py b/timesheet_activity_report/report/timesheet_activity_report.py new file mode 100644 index 00000000..1148bf0d --- /dev/null +++ b/timesheet_activity_report/report/timesheet_activity_report.py @@ -0,0 +1,115 @@ +# © 2016-2019 Elico Corp (https://www.elico-corp.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import models, fields, tools + + +class TimesheetReport(models.Model): + """ + Timesheet Activities Report. + """ + _name = "timesheet.activity.report" + # Database table should not be created, use init() instead + _auto = False + _description = "Timesheet Activities Report" + # Field used for the Name + _rec_name = 'activity_name' + + id = fields.Integer('Id', readonly=True) + activity_type = fields.Selection( + [ + ('task', 'Task'), + ('issue', 'Issue'), + ('timesheet', 'Timesheet'), + ], 'Type', readonly=True, + help="Type is based on the origin of the input (Task, Issue or " + "Timesheet Activities)") + description = fields.Char('Description', readonly=True) + hours = fields.Float( + 'Time spent', digits=(16, 2), readonly=True, + help="Time spent on timesheet") + user_id = fields.Many2one('res.users', 'User', readonly=True) + product_id = fields.Many2one('product.product', 'Product', readonly=True) + date = fields.Date('Date', readonly=True) + project_id = fields.Many2one('project.project', 'Project', readonly=True) + project_state = fields.Char('State', readonly=True, help="Project State") + activity_stage_id = fields.Many2one( + 'project.task.type', 'Stage', + readonly=True, help="Activity Stage") + account_id = fields.Many2one( + 'account.analytic.account', 'Analytic account', readonly=True) + activity_id = fields.Char( + 'Activity id', readonly=True, help="Task id or Issue id") + activity_name = fields.Char( + 'Activity name', readonly=True, help="Task name or Issue name") + categ_id = fields.Many2one( + 'project.category.main', 'Task Cat.', + readonly=True, help="Task Category") + br_id = fields.Many2one( + 'business.requirement', 'Bus. requ.', + readonly=True, help="Business requirement") + partner_id = fields.Many2one( + 'res.partner', 'Customer', readonly=True) + project_categ_id = fields.Many2one( + 'project.project.category', + 'Project Cat.', readonly=True, help="Project Category") + + def init(self, cr): + """ + Timesheet Activities Report. + """ + tools.drop_view_if_exists(cr, 'timesheet_activity_report') + cr.execute(""" + CREATE OR REPLACE VIEW timesheet_activity_report AS ( + SELECT + al.id, + -- Check if the timesheet is linked to a task + -- or an issue + CASE WHEN tw.id IS NOT NULL THEN 'task' + ELSE ( + CASE WHEN i.id IS NOT NULL THEN 'issue' + -- Timesheet created in the timesheet + -- activities panel + ELSE ( + CASE WHEN al.id IS NOT NULL THEN 'timesheet' + -- No timesheet attached to this + -- task/project/BR + ELSE NULL + END + ) + END + ) + END AS activity_type, + -- Description from the task first + -- because the one in the timesheet + -- is wrong when it's linked to a task + al.name AS description, + al.unit_amount AS hours, + al.user_id, + al.product_id, + al.date, + p.id AS project_id, + p.state AS project_state, + COALESCE(t.stage_id, i.stage_id) AS activity_stage_id, + COALESCE(a.id, al.account_id) AS account_id, + COALESCE(t.id, i.id) AS activity_id, + COALESCE(t.name, i.name) AS activity_name, + t.categ_id, + b.id AS br_id, + a.partner_id, + p.project_categ_id + FROM + account_analytic_line al + -- Link with the issue + LEFT OUTER JOIN helpdesk_ticket h + ON h.id = al.helpdesk_ticket_id + -- Link with the project + LEFT OUTER JOIN project_project p + ON p.id = COALESCE(t.project_id, i.project_id) + -- Link with the analytic account + LEFT OUTER JOIN account_analytic_account a + ON a.id = p.analytic_account_id + -- Link with the BR + LEFT OUTER JOIN business_requirement b + ON b.id = p.business_requirement_id + )""") diff --git a/timesheet_activity_report/report/timesheet_activity_report_view.xml b/timesheet_activity_report/report/timesheet_activity_report_view.xml new file mode 100644 index 00000000..999d0b30 --- /dev/null +++ b/timesheet_activity_report/report/timesheet_activity_report_view.xml @@ -0,0 +1,102 @@ + + + + + + Timesheet Activities Tree + timesheet.activity.report + + + + + + + + + + + + + + + + + + + + + + + + Timesheet Activities Pivot Table + timesheet.activity.report + + + + + + + + + Timesheet Completion Analysis + timesheet.activity.report + form + tree,graph + {} + [] + + + + Timesheet Completion Analysis Search + timesheet.activity.report + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/timesheet_activity_report/security/ir.model.access.csv b/timesheet_activity_report/security/ir.model.access.csv new file mode 100644 index 00000000..44035915 --- /dev/null +++ b/timesheet_activity_report/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_timesheet_activity_report,timesheet.activity.report all,model_timesheet_activity_report,base.group_user,1,1,1,1