Skip to content

[17.0][ADD]mail_notify_employee_leave#156

Open
GuillermoNforgeflow wants to merge 1 commit intoOCA:17.0from
ForgeFlow:17.0-add-mail_noify_employee_leave
Open

[17.0][ADD]mail_notify_employee_leave#156
GuillermoNforgeflow wants to merge 1 commit intoOCA:17.0from
ForgeFlow:17.0-add-mail_noify_employee_leave

Conversation

@GuillermoNforgeflow
Copy link
Copy Markdown

@GuillermoNforgeflow GuillermoNforgeflow commented Feb 26, 2026

This module automatically notifies users when they mention or assign a colleague who is out of office. The notification includes the expected return date of the absent user and is sent only once per day per user.

@GuillermoNforgeflow GuillermoNforgeflow changed the title [ADD]mail_notify_employee_leave [17.0][ADD]mail_notify_employee_leave Feb 26, 2026
@GuillermoNforgeflow GuillermoNforgeflow force-pushed the 17.0-add-mail_noify_employee_leave branch 2 times, most recently from a07e0f3 to ed43a5c Compare February 27, 2026 12:38
@GuillermoNforgeflow GuillermoNforgeflow marked this pull request as ready for review February 27, 2026 12:40
@GuillermoNforgeflow GuillermoNforgeflow force-pushed the 17.0-add-mail_noify_employee_leave branch 2 times, most recently from acdda41 to e90ac57 Compare March 5, 2026 11:09
Copy link
Copy Markdown

@AndreuOForgeFlow AndreuOForgeFlow left a comment

Choose a reason for hiding this comment

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

Functional review 👍

Comment thread mail_notify_employee_leave/models/mail_thread.py Outdated
Comment thread mail_notify_employee_leave/models/hr_employee.py
@GuillermoNforgeflow GuillermoNforgeflow force-pushed the 17.0-add-mail_noify_employee_leave branch 4 times, most recently from 63cde2e to aeced1b Compare March 10, 2026 07:01
@GuillermoNforgeflow GuillermoNforgeflow force-pushed the 17.0-add-mail_noify_employee_leave branch from aeced1b to 9d30768 Compare April 1, 2026 06:09
@GuillermoNforgeflow GuillermoNforgeflow force-pushed the 17.0-add-mail_noify_employee_leave branch from 9d30768 to 12ac186 Compare April 1, 2026 06:46
Copy link
Copy Markdown
Contributor

@GuillemCForgeFlow GuillemCForgeFlow left a comment

Choose a reason for hiding this comment

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

it doesn't seem to work for me:

  1. I create a time off for marc demo starting from today (24/4) and finishing next tuesday.
  2. I validate the time off
  3. I send a message to marc demo
Image
  1. I don't receive any reponse
Image

am i doing something wrong?

Comment on lines +8 to +17
"""
Override _validate_leave_request to skip absence notifications when
approving leaves. The context flag 'skip_absence_notification' prevents
_notify_thread from sending messages,
"""
if not self.env.context.get("skip_absence_notification"):
return super(
HrLeave, self.with_context(skip_absence_notification=True)
)._validate_leave_request()
return super()._validate_leave_request()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""
Override _validate_leave_request to skip absence notifications when
approving leaves. The context flag 'skip_absence_notification' prevents
_notify_thread from sending messages,
"""
if not self.env.context.get("skip_absence_notification"):
return super(
HrLeave, self.with_context(skip_absence_notification=True)
)._validate_leave_request()
return super()._validate_leave_request()
return super(HrLeave, self.with_context(skip_absence_notification=True))._validate_leave_request()

is there any reason for doing it as such?

_inherit = "mail.thread"

def _notify_thread(self, message, msg_vals=False, **kwargs):
"""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""

IMHO, we should stick to adding comments in the code only when strictly necessary; this is the same content as what we have in the description.

What'd help more is to have a USAGE.md file to understand more easily the steps you need to do functionally to make it work

cls.record = cls.env["res.partner"].create({"name": "Test Record"})

def test_no_notify_when_user_not_absent(self):
self.employee.is_absent = False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is a computed field. we should create a leave instead to properly test, right?

self.message_notify(
partner_ids=[self.env.user.partner_id.id],
body=body,
subject="User out of office",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can also use the _ for translations here

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.

3 participants