diff --git a/maintenance_timesheet/__init__.py b/maintenance_timesheet/__init__.py index 0650744f6..55ec7fc9a 100644 --- a/maintenance_timesheet/__init__.py +++ b/maintenance_timesheet/__init__.py @@ -1 +1,2 @@ from . import models +from . import reports diff --git a/maintenance_timesheet/report/__init__.py b/maintenance_timesheet/report/__init__.py new file mode 100644 index 000000000..0cb32374b --- /dev/null +++ b/maintenance_timesheet/report/__init__.py @@ -0,0 +1 @@ +from . import timesheets_analysis_report diff --git a/maintenance_timesheet/report/timesheets_analysis_report.py b/maintenance_timesheet/report/timesheets_analysis_report.py new file mode 100644 index 000000000..618bebcf7 --- /dev/null +++ b/maintenance_timesheet/report/timesheets_analysis_report.py @@ -0,0 +1,27 @@ +from odoo import api, fields, models + +class TimesheetsAnalysisReport(models.Model): + _inherit = "timesheets.analysis.report" + + maintenance_request_id = fields.Many2one(comodel_name="maintenance.request", readonly=True) + + @property + def _table_query(self): + return """ + SELECT A.* + FROM ( + %s %s %s + ) A + """ % (self._select(), self._from(), self._where()) + + @api.model + def _select(self): + return super()._select() + """, + A.maintenance_request_id AS maintenance_request_id + """ + + @api.model + def _from(self): + return super()._from() + """ + LEFT JOIN maintenance_request MR ON A.maintenance_request_id = MR.id + """