-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
544 additions
and
302 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
'name': 'Reminders and summaries for timesheet lines', | ||
'version': '16.0.0.0', | ||
'category': 'HR', | ||
'summary': 'Remind employees to fill their timesheets and summarize them to managers', | ||
'description': """ | ||
DESCRIPTION | ||
----------- | ||
This module sends an email notification to each user who hasn't provided at least one timesheet line and that is not in vacation. | ||
In addition, it sends a daily summary to the manager. In addition, it sends a daily summary to managers. It is presented in the form of tables: | ||
- timesheet lines of today | ||
- timesheet lines of the past working day | ||
- timesheet lines of current week | ||
- timesheet lines of current month | ||
""", | ||
'author': 'Nuxly', | ||
'website': 'https://www.nuxly.com', | ||
'depends' : [ | ||
'base', | ||
'hr_timesheet', | ||
'hr_holidays_public' | ||
], | ||
'data': [ | ||
'data/reminder_cron.xml', | ||
'views/mail.xml', | ||
'views/hr_view.xml', | ||
], | ||
'installable': True, | ||
'auto_install': True, | ||
'application': True, | ||
"license": "AGPL-3", | ||
} |
8 changes: 4 additions & 4 deletions
8
...heet_reminder_mail/data/reminder_cron.xml → ..._summary_timesheet/data/reminder_cron.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
12 changes: 6 additions & 6 deletions
12
...sheet_reminder_mail/models/hr_employee.py → ...r_summary_timesheet/models/hr_employee.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from odoo import api, fields, models, _ | ||
|
||
class HrEmployeePrivate(models.Model): | ||
_inherit = 'hr.employee' | ||
|
||
ignore_timesheet_reminder = fields.Boolean(string='Ignore timesheet reminder', store=True, | ||
from odoo import fields, models, _ | ||
|
||
class HrEmployeePrivate(models.Model): | ||
_inherit = 'hr.employee' | ||
|
||
ignore_timesheet_reminder = fields.Boolean(string='Ignore timesheet reminder', store=True, | ||
help="Do not send timesheet mail reminder if checked", groups="hr.group_hr_user", tracking=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from odoo import models, _ | ||
|
||
class HrEmployeePrivate(models.Model): | ||
_inherit = "res.users" | ||
|
||
# Return the different time tables of a given manager | ||
def get_summarized_analytic_lines(self, manager): | ||
return self.env['timesheet.summary'].get_summarized_analytic_lines(manager) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from datetime import datetime, date | ||
import logging | ||
from odoo import models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class TimesheetReminder(models.TransientModel): | ||
_name = 'timesheet.reminder' | ||
_description = "Alert each user who hasn't provided at least one timesheet line and that is not in vacation" | ||
|
||
# Checks that their timesheet lines have been correctly entered by the users | ||
def _cron_timesheet_reminder(self): | ||
holidays_public_line = self.env['hr.holidays.public.line'] | ||
leave = self.env['hr.leave'] | ||
timesheet_line = self.env['account.analytic.line'] | ||
hr_employee = self.env['hr.employee'] | ||
|
||
today = date.today() | ||
today_time = datetime.now() | ||
|
||
_logger.info("Starting the check of employee timesheet lines...") | ||
# Checks if the day is a working day | ||
if today.weekday() in [0, 1, 2, 3, 4]: | ||
# Checks if the day is not a public holiday | ||
holiday = holidays_public_line.search([]).filtered(lambda x: x.date == today) | ||
if not holiday: | ||
# Retrieves only employees who must write at least one timesheet line | ||
employees = hr_employee.search([('ignore_timesheet_reminder', '=', False)]) | ||
for employee in employees: | ||
_logger.info("Check for '%s'.", employee.name) | ||
# Checks if the employee is not on leave | ||
on_leave = leave.search([('employee_id', '=', employee.id)]).filtered( | ||
lambda x: x.number_of_days == 1.0 and x.date_from == today_time or x.date_from <= today_time <= x.date_to) | ||
if not on_leave: | ||
# Checks if the employee has written at least one timesheet line | ||
lines = timesheet_line.search([('date', '=', today), ('employee_id', '=', employee.id)]) | ||
if not lines: | ||
# Preparing the reminder email | ||
self._send_timesheet_reminder( | ||
employee, | ||
'reminder_summary_timesheet.reminder_timesheet_fill', | ||
'hr_timesheet.act_hr_timesheet_line' | ||
) | ||
_logger.info("End of check.") | ||
|
||
# Send an email timesheet line entry reminder to specified users | ||
def _send_timesheet_reminder(self, employees, template_xmlid, action_xmlid, additionnal_values=None): | ||
action_url = '%s/web#menu_id=%s&action=%s' % ( | ||
self.env['ir.config_parameter'].sudo().get_param('web.base.url'), | ||
self.env.ref('hr_timesheet.timesheet_menu_root').id, | ||
self.env.ref(action_xmlid).id, | ||
) | ||
template = self.env.ref(template_xmlid) | ||
template_ctx = {'action_url': action_url} | ||
if additionnal_values: | ||
template_ctx.update(additionnal_values) | ||
for employee in employees: | ||
template.with_context(**template_ctx).send_mail(employee.id) | ||
_logger.info("A timesheet line entry reminder has been sent to '%s'.", employee.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
32 changes: 16 additions & 16 deletions
32
timesheet_reminder_mail/views/hr_view.xml → reminder_summary_timesheet/views/hr_view.xml
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data> | ||
|
||
<record id="hr_employee_view_form_inherit_timesheet_reminder" model="ir.ui.view"> | ||
<field name="name">hr.employee.form.timesheet.reminder</field> | ||
<field name="model">hr.employee</field> | ||
<field name="inherit_id" ref="hr.view_employee_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='timesheet']" position="inside"> | ||
<field name="ignore_timesheet_reminder" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data> | ||
|
||
<record id="hr_employee_view_form_inherit_timesheet_reminder" model="ir.ui.view"> | ||
<field name="name">hr.employee.form.timesheet.reminder</field> | ||
<field name="model">hr.employee</field> | ||
<field name="inherit_id" ref="hr.view_employee_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='application_group']" position="inside"> | ||
<field name="ignore_timesheet_reminder" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.