Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.0][ADD] hr_holiday_notify_employee_manager #331

Merged
merged 6 commits into from
Jun 9, 2017

Conversation

LoisRForgeFlow
Copy link

@LoisRForgeFlow LoisRForgeFlow commented Apr 13, 2017

HR Holiday Notify Employee Manager

This module extends the functionality of the Leaves App to make possible
to notify by mail the manager of the employee requesting the leave.

Configuration

To configure this module, you need to:

#. Go to Settings > Users > Companies.
#. In the company form go to the Configuration tab and in the Leaves
Management
section.
#. Check Leave Requests notified to employee's manager box.

Usage

To use this module, you need to:

#. Go to Leaves > My Leaves > Leaves Request and create a leave request to be
approved.
#. Your manager will be notified by email.

@LoisRForgeFlow LoisRForgeFlow force-pushed the 9.0-add-hr_holidays_notify_approvers branch 2 times, most recently from e2cc220 to f43bf00 Compare April 24, 2017 09:40
@LoisRForgeFlow LoisRForgeFlow changed the title [9.0][ADD] hr_holiday_notify_approver [9.0][ADD] hr_holiday_notify_employee_manager Apr 24, 2017
@LoisRForgeFlow LoisRForgeFlow force-pushed the 9.0-add-hr_holidays_notify_approvers branch from f43bf00 to 8fe8840 Compare April 24, 2017 09:54
Copy link
Member

@JordiBForgeFlow JordiBForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Technical and functional review

Copy link

@jcdrubay jcdrubay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍


def _get_approvers_to_notify(self):
"""Defines who to notify."""
company = self.env['res.company']._company_default_get('hr.holidays')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call directly self.env['res.users']._get_company()?

Or without 'hr.holidays' which is ignored anyway company = self.env['res.company']._company_default_get()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about: self.env.user.company_id?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even better:
self.employee_id.company_id

Because what is needed is the configuration for the company of that employee.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the best

def _get_approvers_to_notify(self):
"""Defines who to notify."""
company = self.env['res.company']._company_default_get('hr.holidays')
if company.leave_notify_manager and self.employee_id.parent_id:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we notify someone by default? in case we forget to set the manager?
Normally, there is only one case of person without manager and he might not input his leave request...

This could be another setting in the company form.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean? by default it notifies the followers of the department, which probably include the department's manager. I don't know if that covers your case... 😕

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know that. Yes it does cover my case. Let's just hope that each department as at least one follower.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, also if you want you can check the first version of this module (79f8095) in which we had more options in who to notify.

approvers = self._get_approvers_to_notify()
if not approvers:
return True
for aprover in approvers:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aprover > approver
:)

@LoisRForgeFlow LoisRForgeFlow force-pushed the 9.0-add-hr_holidays_notify_approvers branch from f79866f to 20dd871 Compare April 28, 2017 14:47
_inherit = 'hr.holidays'

def _get_approvers_to_notify(self):
"""Defines who to notify."""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds ensure_one and @api.multi decorator

company = self.employee_id.company_id
if company.leave_notify_manager and self.employee_id.parent_id:
return self.employee_id.parent_id
else:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-else-return
Use directly return False without else

@api.model
def create(self, vals):
res = super(HrHolidays, self).create(vals)
res._notify_approvers()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a context in order to avoid notify if you are importing information

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you provide a example on how to do it correctly?

Copy link

@moylop260 moylop260 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review lints from travis.

E.g. api.one is seudo-deprecated: https://github.com/odoo/odoo/blob/a9da6e9f3f73674df3354e5e6d8f354e8b26eecb/openerp/api.py#L405
(Better use api.multi plus ensure_one)

@LoisRForgeFlow LoisRForgeFlow force-pushed the 9.0-add-hr_holidays_notify_approvers branch from cc5bccc to e04bb2d Compare April 28, 2017 15:01
@LoisRForgeFlow
Copy link
Author

@moylop260 Thanks for your review, I'm attending it.

HR Holiday Notify Employee Manager
==================================

This module extends the functionality of the Leaves App to make possible

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering the difference with the standard notification/follower system. I would swear that if you are a follower of an employee as manager you receive their leaves/expenses notifications

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, maybe you can explicit the difference here with the standard notification system

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not true. You would become a follower of the employee's leave if you are following his/her department and you would receive a email notification depending on how you've configured yourself as follower of the department. If you are just follower of the employe and/or his/her manager you will neither follow the leave or be notified.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This said, a good use case for this module would be a company with the following requirements:

  • There are several followers by department.
  • Not all of the followers of the department can approve the leaves, but just the ones that are explicitly managers of the employee requesting the leave.

In this case you will have to configure the system in the following way:

  • Configure all the followers of the department to not receive email notifications on leaves requests.
  • Check the box Leave Requests notified to employee's manager added by this module.

JordiBForgeFlow added a commit to ForgeFlow/ao-odoo-buildout that referenced this pull request Jun 8, 2017
@LoisRForgeFlow
Copy link
Author

Hello @moylop260

Can you refresh your review 😬? Thanks!

@moylop260 moylop260 merged commit bb7a31d into OCA:9.0 Jun 9, 2017
@moylop260
Copy link

Thank you!

@LoisRForgeFlow LoisRForgeFlow deleted the 9.0-add-hr_holidays_notify_approvers branch June 12, 2017 08:57
AaronHForgeFlow pushed a commit to ForgeFlow/hr that referenced this pull request Aug 1, 2017
MiquelRForgeFlow pushed a commit to ForgeFlow/hr that referenced this pull request Aug 22, 2017
MiquelRForgeFlow pushed a commit to ForgeFlow/hr that referenced this pull request Sep 20, 2017
feketemihai pushed a commit to feketemihai/hr that referenced this pull request Nov 14, 2017
nikul-serpentcs pushed a commit to nikul-serpentcs/hr that referenced this pull request Jan 20, 2018
nikul-serpentcs pushed a commit to nikul-serpentcs/hr that referenced this pull request Jan 20, 2018
Fix _onchange_employee() arguments

OCA Transbot updated translations from Transifex

OCA Transbot updated translations from Transifex

[fix] `hr_employee_id` use deprecated `sequence.get_id()` (OCA#358)

[add] hr_employee_address_improved (OCA#357)

[ADD] hr_employee_category_parent (OCA#366)

* [ADD] hr_employee_category_parent

* [IMP] human readable name

[UPD] addons table in README.md

[ADD] setup.py

[ADD] hr_holiday_notify_employee_manager: Notify by mail the manager of the employee requesting the leave. (OCA#331)

OCA Transbot updated translations from Transifex

[MIG] hr_holidays_notify_employee_manager: Migration to 10.0

[10.0][ADD] hr_holidays_settings

[FIX] add company_id in view

hr_worked_days_from_timesheet

OCA Transbot updated translations from Transifex

[ADD] hr_worked_days_from_timesheet v10

[IMP] Improved code

[IMP] Improved code

[MIG] hr_employee_legacy_id

[FIX] update header

[UPD] addons table in README.md

[ADD] setup.py

[MIG] 10.0 porting hr_skill

[UPD] Move Skills menu into HR configuration and add widget m2m_tags in employee form view and add to contributors list

[UPD] Update copyright

[IMP] Add unit test to test nam_get function on hr_skill

Refactor code for pep-8

Add group to Skill menu

Fix imports & lost things in pull/300

[UPD] addons table in README.md

[ADD] setup.py

[MIG][9.0] hr_expense_analytic_plans module

OCA Transbot updated translations from Transifex

[MIG] hr_expense_analytic_distribution: Migration to 10.0

[REM] hr_expense_analytic_plans: Replaced by hr_expense_analytic_distribution

[UPD] addons table in README.md

[ADD] setup.py

[FIX] Fix issue with 2 invoices on the same partner and the same total amount (OCA#237)

On the same expense, when we have 2 or more lines with different invoices, and each invoices have the same total amount, reconcile is not possible.

The fix is to exclude reconcile account.move.line, and the first time if we have more than one line to reconcile on the same amount, we keep the first.

OCA Transbot updated translations from Transifex

[MIG] hr_expense_invoice: Migration to 10.0

[UPD] addons table in README.md

[ADD] setup.py

Update view in holidays status, to remove duplicated field on company_id. (OCA#405)

[FIX][hr_holidays_settings] Make 'Leave Types' view accessible (OCA#408)

[MIG] hr_holidays_meeting_name (OCA#334)

* Add hr_holidays_meeting_name module

* Typo

* [MIG] hr_holidays_meeting_name

* [CHG] According upstream changes.

* [CHG] Rewrite hr_holidays_meeting_name witout Odoo patch. Add tests.

* [CHG] Ignore .eggs directory.

[UPD] addons table in README.md

OCA Transbot updated translations from Transifex

[FIX] hr_employee_seniority permission problem

normally hr.contract are only readable by Employee / Officer and Employee / Managers,
not basic employees => we need compute_sudo to compute the employee's seniority otherwise
the employee cannot display his own record.

[FIX] employee seniority tests

[UPD] addons table in README.md

[FIX] holiday meeting name tests

Change the date to avoid conflicts with the demo data of
hr_holidays.

[IMP] hr_public_holidays: Improve README

[FIX] employee seniority search crash

[imp] hr_employee_id: ease override w/ custom ID

[UPD] addons table in README.md
sambarros pushed a commit to sambarros/hr that referenced this pull request Jul 26, 2018
[BSSFL-452] Import and process RMA sent
i-vyshnevska pushed a commit to i-vyshnevska/hr that referenced this pull request Mar 5, 2019
i-vyshnevska pushed a commit to i-vyshnevska/hr that referenced this pull request Mar 12, 2019
quentingigon pushed a commit to quentingigon/hr that referenced this pull request Oct 11, 2019
Mraimou pushed a commit to camptocamp/hr that referenced this pull request Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants