No data yet!
@@ -20,66 +128,25 @@
pivot
-
+
graph
-
+
-
-
- tree
-
-
-
-
-
-
- form
-
-
-
-
-
-
- kanban
-
-
-
-
-
- account.analytic.line.pivot
- account.analytic.line
-
- primary
-
-
-
-
-
-
-
-
- account.analytic.line.graph
- account.analytic.line
-
- primary
-
-
-
-
-
+
Timesheets by Project
- account.analytic.line
+ timesheets.analysis.report
[('project_id', '!=', False)]
- {'grid_range': 'week'}
-
+ {}
+
+ pivot,graph
No data yet!
@@ -93,68 +160,25 @@
pivot
-
+
graph
-
+
-
-
- tree
-
-
-
-
-
-
- form
-
-
-
-
-
-
- kanban
-
-
-
-
-
- account.analytic.line.pivot
- account.analytic.line
-
- primary
-
-
-
-
-
-
-
-
- account.analytic.line.graph
- account.analytic.line
-
- primary
-
-
-
-
-
-
-
+
Timesheets by Task
- account.analytic.line
+ timesheets.analysis.report
[('project_id', '!=', False)]
- {'grid_range': 'week'}
-
+ {}
+
+ pivot,graph
No data yet!
@@ -168,35 +192,14 @@
pivot
-
+
graph
-
-
-
-
-
-
- tree
-
-
-
-
-
-
- form
-
-
-
-
-
-
- kanban
-
+
diff --git a/addons/hr_timesheet/report/timesheets_analysis_report.py b/addons/hr_timesheet/report/timesheets_analysis_report.py
new file mode 100644
index 00000000000..265bada94e0
--- /dev/null
+++ b/addons/hr_timesheet/report/timesheets_analysis_report.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from psycopg2 import sql
+
+from odoo import api, tools, fields, models
+
+
+class TimesheetsAnalysisReport(models.Model):
+ _name = "timesheets.analysis.report"
+ _description = "Timesheets Analysis Report"
+ _auto = False
+
+ name = fields.Char("Description", readonly=True)
+ user_id = fields.Many2one("res.users", string="User", readonly=True)
+ project_id = fields.Many2one("project.project", string="Project", readonly=True)
+ task_id = fields.Many2one("project.task", string="Task", readonly=True)
+ ancestor_task_id = fields.Many2one("project.task", string="Ancestor Task", readonly=True)
+ employee_id = fields.Many2one("hr.employee", string="Employee", readonly=True)
+ manager_id = fields.Many2one("hr.employee", "Manager", readonly=True)
+ company_id = fields.Many2one("res.company", string="Company", readonly=True)
+ department_id = fields.Many2one("hr.department", string="Department", readonly=True)
+ currency_id = fields.Many2one('res.currency', string="Currency", readonly=True)
+ date = fields.Date("Date", readonly=True)
+ amount = fields.Monetary("Amount", readonly=True)
+ unit_amount = fields.Float("Hours Spent", readonly=True)
+
+ @property
+ def _table_query(self):
+ return "%s %s %s" % (self._select(), self._from(), self._where())
+
+ @api.model
+ def _select(self):
+ return """
+ SELECT
+ A.id AS id,
+ A.name AS name,
+ A.user_id AS user_id,
+ A.project_id AS project_id,
+ A.task_id AS task_id,
+ A.ancestor_task_id AS ancestor_task_id,
+ A.employee_id AS employee_id,
+ A.manager_id AS manager_id,
+ A.company_id AS company_id,
+ A.department_id AS department_id,
+ A.currency_id AS currency_id,
+ A.date AS date,
+ A.amount AS amount,
+ A.unit_amount AS unit_amount
+ """
+
+ @api.model
+ def _from(self):
+ return "FROM account_analytic_line A"
+
+ @api.model
+ def _where(self):
+ return "WHERE A.project_id IS NOT NULL"
+
+ @api.model
+ def _get_view(self, view_id=None, view_type='form', **options):
+ result = super()._get_view(view_id, view_type, **options)
+ if view_type in ["pivot", "graph"] and self.env.company.timesheet_encode_uom_id == self.env.ref("uom.product_uom_day"):
+ result["arch"] = self.env["account.analytic.line"]._apply_time_label(result["arch"], related_model=self._name)
+ return result
+
+ def init(self):
+ tools.drop_view_if_exists(self.env.cr, self._table)
+ self.env.cr.execute(
+ sql.SQL("CREATE or REPLACE VIEW {} as ({})").format(
+ sql.Identifier(self._table),
+ sql.SQL(self._table_query)
+ )
+ )
diff --git a/addons/hr_timesheet/security/hr_timesheet_security.xml b/addons/hr_timesheet/security/hr_timesheet_security.xml
index 30081f6ff6a..f58b7fa4df0 100644
--- a/addons/hr_timesheet/security/hr_timesheet_security.xml
+++ b/addons/hr_timesheet/security/hr_timesheet_security.xml
@@ -86,5 +86,10 @@
+
+ Timesheets Analysis Report multi-company
+
+ [('company_id', 'in', company_ids)]
+