diff --git a/addons/hr_holidays/models/mail_channel.py b/addons/hr_holidays/models/mail_channel.py index 3e29066bf08..166caa37d3e 100644 --- a/addons/hr_holidays/models/mail_channel.py +++ b/addons/hr_holidays/models/mail_channel.py @@ -24,4 +24,9 @@ class Channel(models.Model): out_of_office_infos = dict(((res['partner_id'], res) for res in self.env.cr.dictfetchall())) for partner_id, out_of_office_info in out_of_office_infos.items(): partner_infos[partner_id]['out_of_office_date_end'] = out_of_office_info['date_to'] + + # fill empty values for the consistency of the result + for partner_info in partner_infos.values(): + partner_info.setdefault('out_of_office_date_end', False) + return partner_infos diff --git a/addons/hr_holidays/tests/test_out_of_office.py b/addons/hr_holidays/tests/test_out_of_office.py index a035f5afbe2..c0c25075e00 100644 --- a/addons/hr_holidays/tests/test_out_of_office.py +++ b/addons/hr_holidays/tests/test_out_of_office.py @@ -5,7 +5,7 @@ from datetime import datetime from dateutil.relativedelta import relativedelta from odoo.addons.base.tests.common import TransactionCaseWithUserDemo -from odoo.tests.common import tagged, users, warmup, Form +from odoo.tests.common import tagged, users, warmup from odoo.addons.hr_holidays.tests.common import TestHrHolidaysCommon @@ -40,7 +40,7 @@ class TestOutOfOffice(TestHrHolidaysCommon): partner = self.employee_hruser.user_id.partner_id partner2 = self.user_employee.partner_id - channel = self.env['mail.channel'].with_context({ + channel = self.env['mail.channel'].with_user(self.user_employee).with_context({ 'mail_create_nolog': True, 'mail_create_nosubscribe': True, 'mail_channel_noautofollow': True, @@ -51,7 +51,7 @@ class TestOutOfOffice(TestHrHolidaysCommon): 'email_send': False, 'name': 'test' }) - infos = channel.with_user(self.user_employee).channel_info() + infos = channel.channel_info() self.assertEqual(infos[0]['direct_partner'][0]['out_of_office_date_end'], leave_date_end) @tagged('out_of_office')