diff --git a/hr_department_project/README.rst b/hr_department_project/README.rst
new file mode 100644
index 00000000..981bdfe1
--- /dev/null
+++ b/hr_department_project/README.rst
@@ -0,0 +1,36 @@
+*****************************
+Hibou - HR Department Project
+*****************************
+
+Define a default project for every department.
+
+For more information and add-ons, visit `Hibou.io `_.
+
+
+=============
+Main Features
+=============
+
+* Adds new smart button to HR Department form view for projects which displays the number of projects for that department.
+* New project tree view for department-specific projects.
+* Adds new Department field to projects.
+* Adds new filter to group projects by Department.
+
+.. image:: https://user-images.githubusercontent.com/15882954/41183026-42afc7b4-6b2d-11e8-9531-f3e56b92b332.png
+ :alt: 'Project Create'
+ :width: 988
+ :align: left
+
+.. image:: https://user-images.githubusercontent.com/15882954/41183324-fa790b84-6b2e-11e8-956b-3724a4b49e56.png
+ :alt: 'Department Detail'
+ :width: 988
+ :align: left
+
+
+=======
+License
+=======
+
+Please see `LICENSE `_.
+
+Copyright Hibou Corp. 2018
diff --git a/hr_department_project/__init__.py b/hr_department_project/__init__.py
new file mode 100644
index 00000000..a0fdc10f
--- /dev/null
+++ b/hr_department_project/__init__.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from . import models
diff --git a/hr_department_project/__manifest__.py b/hr_department_project/__manifest__.py
new file mode 100644
index 00000000..236f81dc
--- /dev/null
+++ b/hr_department_project/__manifest__.py
@@ -0,0 +1,24 @@
+{
+ 'name': 'HR Department Project',
+ 'version': '17.0.1.0.0',
+ 'author': 'Hibou Corp. ',
+ 'category': 'Human Resources',
+ 'summary': 'Provide default project per Department',
+ 'description': """
+HR Department Project
+=====================
+
+Define a 'default project' for every department. This is a bridge module to allow other modules to use this behavior.
+""",
+ 'website': 'https://hibou.io/',
+ 'depends': [
+ 'project',
+ 'hr',
+ ],
+ 'data': [
+ 'views/hr_views.xml',
+ 'views/project_views.xml',
+ ],
+ 'installable': True,
+ 'auto_install': False,
+}
diff --git a/hr_department_project/models/__init__.py b/hr_department_project/models/__init__.py
new file mode 100644
index 00000000..feb08ba8
--- /dev/null
+++ b/hr_department_project/models/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+from . import hr
+from . import project
diff --git a/hr_department_project/models/hr.py b/hr_department_project/models/hr.py
new file mode 100644
index 00000000..2d0fb2f9
--- /dev/null
+++ b/hr_department_project/models/hr.py
@@ -0,0 +1,22 @@
+from odoo import api, fields, models, _
+
+
+class Department(models.Model):
+ _inherit = 'hr.department'
+
+ project_ids = fields.One2many('project.project', 'department_id', string='Projects')
+ project_count = fields.Integer(compute='_compute_project_count', string='Project Count')
+
+ def _compute_project_count(self):
+ for department in self:
+ department.project_count = len(department.with_context(active_test=False).project_ids)
+
+ def project_tree_view(self):
+ self.ensure_one()
+ action = self.env.ref('project.open_view_project_all').read()[0]
+ action['domain'] = [('department_id', '=', self.id)]
+ action['context'] = {
+ 'default_department_id': self.id,
+ 'default_user_id': self.manager_id.id if self.manager_id else 0,
+ }
+ return action
diff --git a/hr_department_project/models/project.py b/hr_department_project/models/project.py
new file mode 100644
index 00000000..e6bd32f1
--- /dev/null
+++ b/hr_department_project/models/project.py
@@ -0,0 +1,7 @@
+from odoo import api, fields, models, _
+
+
+class Project(models.Model):
+ _inherit = 'project.project'
+
+ department_id = fields.Many2one('hr.department', string='Department')
diff --git a/hr_department_project/views/hr_views.xml b/hr_department_project/views/hr_views.xml
new file mode 100644
index 00000000..478bdb82
--- /dev/null
+++ b/hr_department_project/views/hr_views.xml
@@ -0,0 +1,18 @@
+
+
+
+ hr.department.form.inherited
+ hr.department
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hr_department_project/views/project_views.xml b/hr_department_project/views/project_views.xml
new file mode 100644
index 00000000..7c7af6da
--- /dev/null
+++ b/hr_department_project/views/project_views.xml
@@ -0,0 +1,24 @@
+
+
+
+ project.project.form.inherited
+ project.project
+
+
+
+
+
+
+
+
+
+ project.project.select.inherited
+ project.project
+
+
+
+
+
+
+
+
\ No newline at end of file
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
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..3c54e235
--- /dev/null
+++ b/maintenance_timesheet/__manifest__.py
@@ -0,0 +1,24 @@
+{
+ 'name': 'Equipment Timesheets',
+ 'version': '17.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..70c7ebad
--- /dev/null
+++ b/maintenance_timesheet/models/maintenance.py
@@ -0,0 +1,56 @@
+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.")
+ department_id = fields.Many2one('hr.department')
+
+
+ @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..a9280c0f
--- /dev/null
+++ b/maintenance_timesheet/views/maintenance_views.xml
@@ -0,0 +1,68 @@
+
+
+
+ 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
diff --git a/maintenance_usage/models/maintenance.py b/maintenance_usage/models/maintenance.py
index 3622d5a8..92c17160 100644
--- a/maintenance_usage/models/maintenance.py
+++ b/maintenance_usage/models/maintenance.py
@@ -11,8 +11,8 @@ class MaintenanceEquipmentCategory(models.Model):
class MaintenanceEquipment(models.Model):
_inherit = 'maintenance.equipment'
- employee_id = fields.Many2one(track_visibility=False)
- department_id = fields.Many2one(track_visibility=False)
+ employee_id = fields.Many2one(tracking=False)
+ department_id = fields.Many2one(tracking=False)
usage_qty = fields.Float(string='Usage', default=0.0)
usage_uom_id = fields.Many2one('uom.uom', related='category_id.usage_uom_id')
usage_log_ids = fields.One2many('maintenance.usage.log', 'equipment_id', string='Usage')