From 21d4908ad48dc4437879c79405c1525d99e76e3e Mon Sep 17 00:00:00 2001 From: Reinhard <779081643@qq.com> Date: Tue, 26 Mar 2019 15:11:39 +0800 Subject: [PATCH 1/4] [12.0][[BR001548]][MIG] migrate timesheet_activity_report to 12.0 --- timesheet_activity_report/README.rst | 65 ++++++++++ timesheet_activity_report/__init__.py | 1 + timesheet_activity_report/__manifest__.py | 23 ++++ timesheet_activity_report/report/__init__.py | 1 + .../report/timesheet_activity_report.py | 114 ++++++++++++++++++ .../report/timesheet_activity_report_view.xml | 102 ++++++++++++++++ .../security/ir.model.access.csv | 2 + 7 files changed, 308 insertions(+) create mode 100644 timesheet_activity_report/README.rst create mode 100644 timesheet_activity_report/__init__.py create mode 100644 timesheet_activity_report/__manifest__.py create mode 100644 timesheet_activity_report/report/__init__.py create mode 100644 timesheet_activity_report/report/timesheet_activity_report.py create mode 100644 timesheet_activity_report/report/timesheet_activity_report_view.xml create mode 100644 timesheet_activity_report/security/ir.model.access.csv diff --git a/timesheet_activity_report/README.rst b/timesheet_activity_report/README.rst new file mode 100644 index 00000000..85667669 --- /dev/null +++ b/timesheet_activity_report/README.rst @@ -0,0 +1,65 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-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. + + +Installation +============ + +To install this module, you need to have basic modules installed: + +* project_timesheet +* project_issue_sheet +* business_requirement_deliverable_project +* project_task_category + +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 + + +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..2c2c7b71 --- /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': 'AGPL-3', + 'website': 'https://www.elico-corp.com', + 'data': [ + 'report/timesheet_activity_report_view.xml', + 'security/ir.model.access.csv', + ], + 'installable': False, + '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..95c315cb --- /dev/null +++ b/timesheet_activity_report/report/timesheet_activity_report.py @@ -0,0 +1,114 @@ +# © 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 From bf295eea4e817725a113898f01540241af5bd499 Mon Sep 17 00:00:00 2001 From: Reinhard <779081643@qq.com> Date: Tue, 26 Mar 2019 15:13:54 +0800 Subject: [PATCH 2/4] [FIX] copyright --- timesheet_activity_report/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timesheet_activity_report/__manifest__.py b/timesheet_activity_report/__manifest__.py index 2c2c7b71..232da91b 100644 --- a/timesheet_activity_report/__manifest__.py +++ b/timesheet_activity_report/__manifest__.py @@ -12,12 +12,12 @@ ], 'author': 'Elico Corp', 'support': 'support@elico-corp.com', - 'license': 'AGPL-3', + 'license': 'LGPL-3', 'website': 'https://www.elico-corp.com', 'data': [ 'report/timesheet_activity_report_view.xml', 'security/ir.model.access.csv', ], - 'installable': False, + 'installable': True, 'application': False } From b53e628c8b07c370fa9243c1d633b6b32cfdbaac Mon Sep 17 00:00:00 2001 From: Reinhard <779081643@qq.com> Date: Tue, 26 Mar 2019 15:17:37 +0800 Subject: [PATCH 3/4] [FIX] readme --- timesheet_activity_report/README.rst | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/timesheet_activity_report/README.rst b/timesheet_activity_report/README.rst index 85667669..ae17bd16 100644 --- a/timesheet_activity_report/README.rst +++ b/timesheet_activity_report/README.rst @@ -1,6 +1,6 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 +.. 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 @@ -10,16 +10,6 @@ This module extends the functionality of project adding a timesheet report liste You can use this report to communicate the timesheet analysis to the project members. -Installation -============ - -To install this module, you need to have basic modules installed: - -* project_timesheet -* project_issue_sheet -* business_requirement_deliverable_project -* project_task_category - Bug Tracker =========== @@ -42,6 +32,7 @@ Contributors * Eric Caudal * Sébastien Maillard +* Reinhard Sheng This module is maintained by Elico Corporation. From e5991458fc2916f2c5824c904f38356baff78e15 Mon Sep 17 00:00:00 2001 From: Reinhard <779081643@qq.com> Date: Tue, 26 Mar 2019 15:58:46 +0800 Subject: [PATCH 4/4] [FIX] pep8 --- timesheet_activity_report/report/timesheet_activity_report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/timesheet_activity_report/report/timesheet_activity_report.py b/timesheet_activity_report/report/timesheet_activity_report.py index 95c315cb..1148bf0d 100644 --- a/timesheet_activity_report/report/timesheet_activity_report.py +++ b/timesheet_activity_report/report/timesheet_activity_report.py @@ -101,7 +101,8 @@ def init(self, cr): FROM account_analytic_line al -- Link with the issue - LEFT OUTER JOIN helpdesk_ticket h ON h.id = al.helpdesk_ticket_id + 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)