-
-
Notifications
You must be signed in to change notification settings - Fork 674
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
[9.0][ADD] hr_holiday_notify_employee_manager #331
Conversation
e2cc220
to
f43bf00
Compare
f43bf00
to
8fe8840
Compare
There was a problem hiding this 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
There was a problem hiding this 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') |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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... 😕
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aprover > approver
:)
f79866f
to
20dd871
Compare
_inherit = 'hr.holidays' | ||
|
||
def _get_approvers_to_notify(self): | ||
"""Defines who to notify.""" |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this 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)
cc5bccc
to
e04bb2d
Compare
@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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Hello @moylop260 Can you refresh your review 😬? Thanks! |
Thank you! |
…of the employee requesting the leave. (OCA#331)
…of the employee requesting the leave. (OCA#331)
…of the employee requesting the leave. (OCA#331)
…of the employee requesting the leave. (OCA#331)
…of the employee requesting the leave. (OCA#331)
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
[BSSFL-452] Import and process RMA sent
…of the employee requesting the leave. (OCA#331)
…of the employee requesting the leave. (OCA#331)
…of the employee requesting the leave. (OCA#331)
forecast updates
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.