From 87bc7b5c3f59ebc4b8497c458a8fa5a3ae4f6ae4 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Tue, 24 Apr 2018 09:55:23 -0700 Subject: [PATCH 1/3] Initial commit `maintenance_timesheet` for 11.0 --- maintenance_timesheet/__init__.py | 1 + maintenance_timesheet/__manifest__.py | 24 +++++++ maintenance_timesheet/models/__init__.py | 1 + maintenance_timesheet/models/maintenance.py | 55 +++++++++++++++ .../views/maintenance_views.xml | 67 +++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 maintenance_timesheet/__init__.py create mode 100644 maintenance_timesheet/__manifest__.py create mode 100644 maintenance_timesheet/models/__init__.py create mode 100644 maintenance_timesheet/models/maintenance.py create mode 100644 maintenance_timesheet/views/maintenance_views.xml diff --git a/maintenance_timesheet/__init__.py b/maintenance_timesheet/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/maintenance_timesheet/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py new file mode 100644 index 00000000..bca3e0b5 --- /dev/null +++ b/maintenance_timesheet/__manifest__.py @@ -0,0 +1,24 @@ +{ + 'name': 'Equipment Timesheets', + 'version': '11.0.1.0.0', + 'author': 'Hibou Corp. ', + 'category': 'Human Resources', + 'summary': 'Record time on maintenance requests.', + 'description': """ +Equipment Timesheets +==================== + +Adds Timesheets to Maintenance Requests to record time and labor costs. +""", + 'website': 'https://hibou.io/', + 'depends': [ + 'maintenance_notebook', + 'hr_department_project', + 'hr_timesheet', + ], + 'data': [ + 'views/maintenance_views.xml', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/maintenance_timesheet/models/__init__.py b/maintenance_timesheet/models/__init__.py new file mode 100644 index 00000000..12bf298f --- /dev/null +++ b/maintenance_timesheet/models/__init__.py @@ -0,0 +1 @@ +from . import maintenance diff --git a/maintenance_timesheet/models/maintenance.py b/maintenance_timesheet/models/maintenance.py new file mode 100644 index 00000000..202338af --- /dev/null +++ b/maintenance_timesheet/models/maintenance.py @@ -0,0 +1,55 @@ +from odoo import api, fields, models + + +class AnalyticLine(models.Model): + _inherit = 'account.analytic.line' + + maintenance_request_id = fields.Many2one('maintenance.request') + + +class MaintenanceEquipment(models.Model): + _inherit = 'maintenance.equipment' + + def action_open_maintenance_requests(self): + self.ensure_one() + action = self.env.ref('maintenance.hr_equipment_request_action_from_equipment').read()[0] + action['domain'] = [('equipment_id', '=', self.id)] + action['context'] = { + 'default_equipment_id': self.id, + 'default_employee_id': self.employee_id.id, + 'default_department_id': self.department_id.id, + } + return action + + +class MaintenanceRequest(models.Model): + _inherit = 'maintenance.request' + + project_id = fields.Many2one('project.project', string='Billing Project') + timesheet_ids = fields.One2many('account.analytic.line', 'maintenance_request_id', 'Timesheets') + effective_hours = fields.Float(compute='_hours_get', store=True, string='Hours Spent', + help="Computed using the sum of the maintenance work done.") + remaining_hours = fields.Float(compute='_hours_get', store=True, string='Remaining Hours', + help="Total remaining time.") + + @api.model + def create(self, values): + if not values.get('project_id') and values.get('department_id'): + department = self.env['hr.department'].browse(values.get('department_id')) + if department and department.project_ids: + values.update({'project_id': department.project_ids.ids[0]}) + return super(MaintenanceRequest, self).create(values) + + @api.depends('duration', 'timesheet_ids.unit_amount') + def _hours_get(self): + for request in self: + effective_hours = sum(request.sudo().timesheet_ids.mapped('unit_amount')) + request.effective_hours = effective_hours + request.remaining_hours = (request.duration or 0.0) - effective_hours + + @api.onchange('department_id') + def _onchange_department_id_project(self): + for request in self: + if request.department_id and request.department_id.project_ids: + request.project_id = request.department_id.project_ids[0] + diff --git a/maintenance_timesheet/views/maintenance_views.xml b/maintenance_timesheet/views/maintenance_views.xml new file mode 100644 index 00000000..f304b368 --- /dev/null +++ b/maintenance_timesheet/views/maintenance_views.xml @@ -0,0 +1,67 @@ + + + + equipment.form.inherited + maintenance.equipment + + + + + + + + + + maintenance.request.view.form.inherit.hr.inherited + maintenance.request + + + + + + + + + + + equipment.request.form.notebook.inherited + maintenance.request + + + + + + + + + + + + + + + + + + + + + + + + + + + equipment.request.tree.inherited + maintenance.request + + + + + + + + \ No newline at end of file From 3e8b027d0f86aab8ce770cfd84c38cb992df8f0b Mon Sep 17 00:00:00 2001 From: Kristen Marie Kulha Date: Mon, 11 Jun 2018 16:37:31 -0700 Subject: [PATCH 2/3] Add README to maintenance_timesheet. --- maintenance_timesheet/README.rst | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 maintenance_timesheet/README.rst diff --git a/maintenance_timesheet/README.rst b/maintenance_timesheet/README.rst new file mode 100644 index 00000000..81bbdb7f --- /dev/null +++ b/maintenance_timesheet/README.rst @@ -0,0 +1,34 @@ +***************************** +Hibou - Maintenance Timesheet +***************************** + +Record time on maintenance requests. + +For more information and add-ons, visit `Hibou.io `_. + + +============= +Main Features +============= + +* Adds Timesheets to Maintenance Requests to record time and labor costs. +* New 'Timesheets' notebook tab on Maintenance Request form. + +.. image:: https://user-images.githubusercontent.com/15882954/41261982-394a10b8-6d93-11e8-9602-c19a3e20065d.png + :alt: 'Equipment Detail' + :width: 988 + :align: left + +===== +Notes +===== + +* In order to add time sheets, you must first select a Billing Project from the dropdown menu. + +======= +License +======= + +Please see `LICENSE `_. + +Copyright Hibou Corp. 2018 From 236ba4af222fd57b59183584ea021c2402c8ff89 Mon Sep 17 00:00:00 2001 From: Bhoomi Date: Thu, 29 Aug 2019 13:46:58 -0400 Subject: [PATCH 3/3] MIG `maintenance_timesheet` For Odoo 12.0 --- maintenance_timesheet/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maintenance_timesheet/__manifest__.py b/maintenance_timesheet/__manifest__.py index bca3e0b5..018f2ced 100644 --- a/maintenance_timesheet/__manifest__.py +++ b/maintenance_timesheet/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'Equipment Timesheets', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'Hibou Corp. ', 'category': 'Human Resources', 'summary': 'Record time on maintenance requests.',