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();