diff --git a/timesheet_activity_report/report/timesheet_activity_report.py b/timesheet_activity_report/report/timesheet_activity_report.py index 851da1a5..747a8f7b 100644 --- a/timesheet_activity_report/report/timesheet_activity_report.py +++ b/timesheet_activity_report/report/timesheet_activity_report.py @@ -33,9 +33,9 @@ class TimesheetReport(models.Model): 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") + project_state = fields.Char('Project state', readonly=True, help="Project State") activity_stage_id = fields.Many2one( - 'project.task.type', 'Stage', + 'project.task.type', 'Activity stage', readonly=True, help="Activity Stage") account_id = fields.Many2one( 'account.analytic.account', 'Analytic account', readonly=True) @@ -50,7 +50,7 @@ class TimesheetReport(models.Model): 'business.requirement', 'Bus. requ.', readonly=True, help="Business requirement") partner_id = fields.Many2one( - 'res.partner', 'Customer', readonly=True) + 'res.partner', 'Stakeholder', readonly=True) project_categ_id = fields.Many2one( 'project.project.category', 'Project Cat.', readonly=True, help="Project Category") diff --git a/timesheet_activity_report_improve/README.rst b/timesheet_activity_report_improve/README.rst new file mode 100644 index 00000000..effc21be --- /dev/null +++ b/timesheet_activity_report_improve/README.rst @@ -0,0 +1,70 @@ +.. 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 Improve +================================= + +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: + +* timesheet_activity_report + +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 +* Miya Xing + + +Maintainer +---------- + +.. image:: https://www.elico-corp.com/logo.png + :alt: Elico Corp + :target: https://www.elico-corp.com + +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_improve/__init__.py b/timesheet_activity_report_improve/__init__.py new file mode 100644 index 00000000..329701fb --- /dev/null +++ b/timesheet_activity_report_improve/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2015-2017 Elico corp (https://www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/timesheet_activity_report_improve/__manifest__.py b/timesheet_activity_report_improve/__manifest__.py new file mode 100644 index 00000000..3b70aec6 --- /dev/null +++ b/timesheet_activity_report_improve/__manifest__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2015-2017 Elico corp (https://www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Timesheet Activities Report', + 'version': '10.0.1.1.0', + 'category': 'Human Resources', + 'depends': [ + 'timesheet_activity_report', + ], + 'author': 'Elico Corp', + 'support': 'support@elico-corp.com', + 'license': 'AGPL-3', + 'website': 'https://www.elico-corp.com', + 'data': [ + 'views/timesheet_report_improve.xml', + 'views/button_view.xml', + ], + 'installable': True, + 'application': True +} diff --git a/timesheet_activity_report_improve/models/__init__.py b/timesheet_activity_report_improve/models/__init__.py new file mode 100644 index 00000000..36a3038c --- /dev/null +++ b/timesheet_activity_report_improve/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import timesheet_activity_report_improve +from . import button_fuction diff --git a/timesheet_activity_report_improve/models/button_fuction.py b/timesheet_activity_report_improve/models/button_fuction.py new file mode 100644 index 00000000..758ce3de --- /dev/null +++ b/timesheet_activity_report_improve/models/button_fuction.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico Corp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, api, _ + + +class BRButtonFunction(models.Model): + _inherit = "business.requirement" + + @api.multi + def br_open_tms_activity_report(self): + for record in self: + domain = [('br_id', '=', record.id)] + return { + 'name': _('BR_timesheet_activity_report'), + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'graph', + 'res_model': 'timesheet.activity.report', + 'target': 'current', + 'domain': domain, + } + + +class ProjectButtonFunction(models.Model): + _inherit = "project.project" + + @api.multi + def project_open_tms_activity_rep(self): + for record in self: + domain = [('project_id', '=', record.id)] + return { + 'name': _('Project_timesheet_activity_report'), + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'graph', + 'res_model': 'timesheet.activity.report', + 'target': 'current', + 'domain': domain, + } diff --git a/timesheet_activity_report_improve/models/timesheet_activity_report_improve.py b/timesheet_activity_report_improve/models/timesheet_activity_report_improve.py new file mode 100644 index 00000000..62b66388 --- /dev/null +++ b/timesheet_activity_report_improve/models/timesheet_activity_report_improve.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico Corp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, fields, api, tools + + +class TimesheetReportImprove(models.Model): + _inherit = 'timesheet.activity.report' + + br_master_project = fields.Many2one( + 'project.project', string='BR Master Pro.' + ) + br_status = fields.Selection( + [('draft', 'Draft'), + ('confirmed', 'Confirmed'), + ('approved', 'Approved'), + ('stakeholder_approval', 'Stakeholder Approval'), + ('in_progress', 'In progress'), + ('done', 'Done'), + ('cancel', 'Cancel'), + ('drop', 'Drop')], + string='BR status', + ) + department_id = fields.Many2one('hr.department', string='Department') + + def _select(self): + select_str = """ + SELECT + ts.id, + -- Check if the timesheet is linked to a task + -- or an issue + CASE WHEN (select id from project_task where id = al.task_id) + IS NOT NULL THEN 'task' + ELSE ( + CASE WHEN (select id from project_issue where id = + al.issue_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 + b.state AS br_status, + b.project_id AS br_master_project, + em.department_id AS department_id, + CASE WHEN p.active = True THEN 'Active' + WHEN p.active=False THEN 'Archived' END AS project_state, + COALESCE((select name from project_task where id = + al.task_id), al.name) AS description, + al.unit_amount AS hours, + al.user_id, + al.product_id, + al.date, + al.project_id, + COALESCE((select stage_id from project_task where id = + al.task_id), (select stage_id from project_issue where id = + al.issue_id)) AS activity_stage_id, + COALESCE(a.id, al.account_id) AS account_id, + COALESCE((select id from project_task where id = al.task_id), + (select id from project_issue where id = al.issue_id)) + AS activity_id, + COALESCE((select name from project_task where id = + al.task_id), (select name from project_issue where id = + al.issue_id)) AS activity_name, + (select categ_id from project_task where id = + al.task_id) AS categ_id, + b.id AS br_id, + a.partner_id, + (select project_categ_id from project_project where id = + al.project_id) + """ + return select_str + + def _from(self): + from_str = """ + hr_timesheet_sheet_sheet ts + LEFT OUTER JOIN account_analytic_line al + ON ts.id = al.sheet_id + LEFT OUTER JOIN account_analytic_account a + ON a.id = al.account_id + LEFT OUTER JOIN res_users ru + ON ru.id = al.user_id + LEFT OUTER JOIN res_partner rp + on rp.id = ru.partner_id + LEFT OUTER JOIN hr_employee em + on em.name_related = rp.name + LEFT OUTER JOIN project_project p + on a.id = p.analytic_account_id + LEFT OUTER JOIN business_requirement b + ON b.id = (select business_requirement_id from project_project + where id = al.project_id) + """ + return from_str + + @api.model_cr + def init(self): + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute("""CREATE or REPLACE VIEW %s as ( + %s + FROM ( %s ) + )""" % (self._table, self._select(), self._from())) diff --git a/timesheet_activity_report_improve/views/button_view.xml b/timesheet_activity_report_improve/views/button_view.xml new file mode 100644 index 00000000..1328a094 --- /dev/null +++ b/timesheet_activity_report_improve/views/button_view.xml @@ -0,0 +1,31 @@ + + + + business.requirement.form + business.requirement + + + + + + + + + + project.project.form + project.project + + + + + + + + diff --git a/timesheet_activity_report_improve/views/timesheet_report_improve.xml b/timesheet_activity_report_improve/views/timesheet_report_improve.xml new file mode 100644 index 00000000..3c055a5c --- /dev/null +++ b/timesheet_activity_report_improve/views/timesheet_report_improve.xml @@ -0,0 +1,23 @@ + + + + timesheet.activity.report.tree + timesheet.activity.report + + + + + + + + + + + + + + + + +