From b14268ef1bfd0091526255e390255ad664f3839a Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 08:15:14 +0100 Subject: [PATCH] fix: hotfix createAbsence --- modules/worker/back/methods/worker/createAbsence.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index e46ce9577..93ca7fd89 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -128,7 +128,10 @@ module.exports = Self => { const account = await models.VnUser.findById(userId, null, myOptions); const subordinated = await models.VnUser.findById(id, null, myOptions); const worker = await models.Worker.findById(subordinated.id, null, myOptions); - const departmentBoss = await models.VnUser.findById(worker.bossFk, null, myOptions); + const receiver = await models.EmailUser.findOne({ + fields: ['email'], + where: {userFk: worker.bossFk} + }, myOptions); const url = await Self.app.models.Url.getUrl(); const body = $t('Created absence', { author: account.nickname, @@ -140,7 +143,7 @@ module.exports = Self => { await models.Mail.create({ subject: $t('Absence change notification on the labour calendar'), body: body, - receiver: departmentBoss.email + receiver: receiver.email }, myOptions); if (tx) await tx.commit();