[FIX] bemade_time_off_follower: validation error
Fixes a validation error that occurred when the alternate follower was already in the list of recipients for the mail.thread.
This commit is contained in:
parent
626d4c5dc2
commit
017bde45dd
2 changed files with 25 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Time Off Alternative Follower",
|
||||
"version": "17.0.0.0.2",
|
||||
"version": "17.0.0.0.3",
|
||||
"category": "Extra Tools",
|
||||
"summary": "Add Alternative Follower When Receiving Message While On Time Off",
|
||||
"author": "Bemade",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class MailThread(models.AbstractModel):
|
|||
|
||||
# Get the current datetime
|
||||
now = fields.Datetime.now()
|
||||
|
||||
recipient_partner_ids = [recipient["id"] for recipient in recipients]
|
||||
# Loop through each recipient
|
||||
for recipient in recipients:
|
||||
# Search for a user with the same partner_id as the recipient
|
||||
|
|
@ -59,21 +59,30 @@ class MailThread(models.AbstractModel):
|
|||
and leave.alternate_follower_id.partner_id.id not in recipients
|
||||
):
|
||||
# Log the addition of the alternate follower
|
||||
_logger.info(
|
||||
f"Adding {leave.alternate_follower_id.partner_id.name} as follower for {employee.name} "
|
||||
f"while on time off."
|
||||
)
|
||||
# Add the alternate follower to the recipients list
|
||||
recipients.append(
|
||||
{
|
||||
"id": leave.alternate_follower_id.partner_id.id,
|
||||
"active": True,
|
||||
"share": False,
|
||||
"groups": leave.alternate_follower_id.groups_id.ids,
|
||||
"notif": "inbox",
|
||||
"type": "user",
|
||||
}
|
||||
)
|
||||
alternate_follower_id = (
|
||||
leave.alternate_follower_id.partner_id.id)
|
||||
if alternate_follower_id not in recipient_partner_ids:
|
||||
_logger.info(
|
||||
f"Adding {leave.alternate_follower_id.partner_id.name} as follower for {employee.name} "
|
||||
f"while on time off."
|
||||
)
|
||||
recipients.append(
|
||||
{
|
||||
"id": leave.alternate_follower_id.partner_id.id,
|
||||
"active": True,
|
||||
"share": False,
|
||||
"groups": leave.alternate_follower_id.groups_id.ids,
|
||||
"notif": "inbox",
|
||||
"type": "user",
|
||||
}
|
||||
)
|
||||
else:
|
||||
_logger.info(
|
||||
f"{leave.alternate_follower_id.partner_id.name}"
|
||||
f" is already a recipient. Skipping alternate "
|
||||
f"follower addition."
|
||||
)
|
||||
else:
|
||||
_logger.info(
|
||||
f"Not adding {leave.alternate_follower_id.partner_id.name} for {employee.name}, All ready "
|
||||
|
|
|
|||
Loading…
Reference in a new issue